summaryrefslogtreecommitdiff
path: root/examples/alias_startup.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-16 20:40:06 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-16 20:40:06 -0400
commit411f19334de2663d159428538e61a80aa7c98bad (patch)
treeb5c2bd3aa30a910fc7822b96485c15d224ed048a /examples/alias_startup.py
parentf0429e3f96a11572abcd07248730da8219b40c5c (diff)
downloadcmd2-git-411f19334de2663d159428538e61a80aa7c98bad.tar.gz
Added ability to specify a startup_script in cmd2.Cmd.__init__()
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()