summaryrefslogtreecommitdiff
path: root/examples/alias_startup.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-17 14:34:04 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-17 14:34:04 -0400
commitadbcec5c9ee34bd2cd683c2574e94594de1f3267 (patch)
treec363c5042e2eda6fbf5d48c7914a5a93410f1a17 /examples/alias_startup.py
parent51b740dc598e1d3fa879252f4ce0cbcd65b19e79 (diff)
parent7d4778420afda48043a0ec9aca527cbe27ae75ff (diff)
downloadcmd2-git-adbcec5c9ee34bd2cd683c2574e94594de1f3267.tar.gz
Merge branch 'master' into quoted_completion
Diffstat (limited to 'examples/alias_startup.py')
-rwxr-xr-xexamples/alias_startup.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/alias_startup.py b/examples/alias_startup.py
new file mode 100755
index 00000000..23e51048
--- /dev/null
+++ b/examples/alias_startup.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# coding=utf-8
+"""A simple example demonstrating the following:
+ 1) How to add custom command aliases using the alias command
+ 2) How to load an initialization script at startup
+"""
+import argparse
+
+import cmd2
+import pyparsing
+
+from cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args
+
+
+class AliasAndStartup(cmd2.Cmd):
+ """ Example cmd2 application where we create commands that just print the arguments they are called with."""
+
+ def __init__(self):
+ cmd2.Cmd.__init__(self, startup_script='.cmd2rc')
+
+
+if __name__ == '__main__':
+ app = AliasAndStartup()
+ app.cmdloop()