diff options
author | Mike Crute <mike@crute.us> | 2020-05-29 21:11:25 -0700 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2020-05-29 21:11:25 -0700 |
commit | df53323de95796a71ff23a323dfb34dd7214272e (patch) | |
tree | b465b52aea958d1ad605a667da2fa7456f8aa420 | |
parent | b53492723dc99400d0caac6b6c007adf2f9af6fb (diff) | |
download | alpine-ec2-ami-df53323de95796a71ff23a323dfb34dd7214272e.tar.bz2 alpine-ec2-ami-df53323de95796a71ff23a323dfb34dd7214272e.tar.xz alpine-ec2-ami-df53323de95796a71ff23a323dfb34dd7214272e.zip |
Add some more python docs
-rwxr-xr-x | scripts/builder.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/builder.py b/scripts/builder.py index 021016b..ace706d 100755 --- a/scripts/builder.py +++ b/scripts/builder.py | |||
@@ -662,6 +662,8 @@ class FullBuild: | |||
662 | 662 | ||
663 | 663 | ||
664 | def find_repo_root(): | 664 | def find_repo_root(): |
665 | """Find the root of the repo, which contains a .git folder | ||
666 | """ | ||
665 | path = os.getcwd() | 667 | path = os.getcwd() |
666 | 668 | ||
667 | while ".git" not in set(os.listdir(path)) and path != "/": | 669 | while ".git" not in set(os.listdir(path)) and path != "/": |
@@ -674,6 +676,33 @@ def find_repo_root(): | |||
674 | 676 | ||
675 | 677 | ||
676 | def main(): | 678 | def main(): |
679 | """An introspective main method | ||
680 | |||
681 | Just some silly metaprogramming to make commands really easy to write and | ||
682 | to avoid needing to hand register them. Commands have a specific interface, | ||
683 | per below, but should be really easy to create and will be auto discovered. | ||
684 | |||
685 | Commands are objects that have the following attributes: | ||
686 | |||
687 | __doc__ (python docstring) | ||
688 | used as help text in the CLI | ||
689 | |||
690 | command_name (string) | ||
691 | name of the command as invoked by the cli | ||
692 | |||
693 | add_args(parser) (class or static method) | ||
694 | passed an argparse subparser at setup time that will ultimately | ||
695 | handle the arguments for the command at runtime. Should add any | ||
696 | configuration necessary for the command to use later. Must not | ||
697 | rely on object state as it is not invoked with an instance of the | ||
698 | object. | ||
699 | |||
700 | run(self, args, root) (instance method) | ||
701 | passed the arguments object as parsed by argparse as well as a | ||
702 | string indicating the root of the repository (the folder containing | ||
703 | the .git folder). Should throw exceptions on error and return when | ||
704 | completed. Should *not* execute sys.exit | ||
705 | """ | ||
677 | dispatch = {} | 706 | dispatch = {} |
678 | 707 | ||
679 | parser = argparse.ArgumentParser() | 708 | parser = argparse.ArgumentParser() |