File: commandset_custominit.py

package info (click to toggle)
cmd2 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,664 kB
  • sloc: python: 17,488; makefile: 114; sh: 39; javascript: 7
file content (22 lines) | stat: -rw-r--r-- 545 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""A simple example demonstrating a loadable command set."""

from cmd2 import (
    CommandSet,
    Statement,
    with_default_category,
)


@with_default_category('Custom Init')
class CustomInitCommandSet(CommandSet):
    def __init__(self, arg1, arg2) -> None:
        super().__init__()

        self._arg1 = arg1
        self._arg2 = arg2

    def do_show_arg1(self, _: Statement) -> None:
        self._cmd.poutput('Arg1: ' + self._arg1)

    def do_show_arg2(self, _: Statement) -> None:
        self._cmd.poutput('Arg2: ' + self._arg2)