From 411f19334de2663d159428538e61a80aa7c98bad Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Fri, 16 Mar 2018 20:40:06 -0400 Subject: Added ability to specify a startup_script in cmd2.Cmd.__init__() --- examples/alias_startup.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 examples/alias_startup.py (limited to 'examples/alias_startup.py') 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() -- cgit v1.2.1