aboutsummaryrefslogtreecommitdiff
path: root/docs/source/examples/greeter.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2022-03-12 20:20:15 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2022-03-12 20:20:15 +0100
commit049f21cfe779dbcd795d04917dff4ec3034a1546 (patch)
treed2a6de4168709cb01324a37619d4c350128ec6ee /docs/source/examples/greeter.py
parent11da28ef036aeb872f1e5c509b43ae6b9bb64da2 (diff)
Beginning of a tutorial in the docs
Diffstat (limited to 'docs/source/examples/greeter.py')
-rwxr-xr-xdocs/source/examples/greeter.py40
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()