diff options
Diffstat (limited to 'docs/source/examples')
| -rwxr-xr-x | docs/source/examples/greeter.py | 40 | 
1 files changed, 40 insertions, 0 deletions
| diff --git a/docs/source/examples/greeter.py b/docs/source/examples/greeter.py new file mode 100755 index 0000000..5a978f4 --- /dev/null +++ b/docs/source/examples/greeter.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +import hazwaz + + +class World(hazwaz.Command): +    """ +    Greet the whole world. +    """ + +    def main(self): +        print("Hello world!") + + +class Individual(hazwaz.Command): +    """ +    Greet an individual. +    """ + +    def add_arguments(self, parser): +        parser.add_argument( +            "gretee", +            help="The person to be greeted", +        ) + +    def main(self): +        print("Hello {}".format(self.args.gretee)) + + +class Greet(hazwaz.MainCommand): +    """ +    Greet people in different ways. +    """ +    commands = ( +        World(), +        Individual(), +    ) + + +if __name__ == "__main__": +    Greet().run() | 
