File: alias_startup.py

package info (click to toggle)
cmd2 2.5.11%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 10,244 kB
  • sloc: python: 19,643; makefile: 73; sh: 67; javascript: 30
file content (29 lines) | stat: -rwxr-xr-x 736 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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 run an initialization script at startup
"""

import os

import cmd2


class AliasAndStartup(cmd2.Cmd):
    """Example cmd2 application where we create commands that just print the arguments they are called with."""

    def __init__(self):
        alias_script = os.path.join(os.path.dirname(__file__), '.cmd2rc')
        super().__init__(startup_script=alias_script)

    def do_nothing(self, args):
        """This command does nothing and produces no output."""
        pass


if __name__ == '__main__':
    import sys

    app = AliasAndStartup()
    sys.exit(app.cmdloop())