Skip to content
This repository was archived by the owner on Mar 15, 2026. It is now read-only.

Create a new command on CSTAR CLI

Tommaso Lencioni edited this page May 30, 2022 · 3 revisions
  1. Create a new Python Package under src/cstar-cli/cstar/cli .
src
├── cstar-cli
│   ├── cstar
│   │   ├── cli
│   │   │   ├── bpd
│   │   │   ├── rtd
│   │   │   ├── tae
│   │   │   └── mycmd
  1. Add in src/cstar-cli/setup.py your command (short) in packages.

E.g. packages=['cstar.cli', 'cstar.cli.bpd', 'cstar.cli.rtd', 'cstar.cli.tae', 'cstar.cli.mycmd'],

  1. Copy an existing .py file (e.g. transactionfilter.py).

  2. Rename the class and methods to be called

  3. Create a new __init__.py file (if not automatically created) in the package and import the new class created:

from .newfilename import Myclassname
  1. Add you argument to be parsed in parser.py
src
└── cstar-cli-core
    ├── cstar
    │   └── cli
    │       └── core
    │           └── parser.py

E.g.

mycmd_parser = subsystem_parser.add_parser("mycmd").add_subparsers(dest="command")

# The argument must be the name of the .py file
my_new_command = tae_parser.add_parser("myclassname")
# Mandatory, takes as argument the name of the method (defined in the .py file) to run 
my_new_command.add_argument("--action")
  1. ⚠️ ALLWAYS RUN ./install.sh BEFORE TESTING NEW FEATURES ⚠️

  2. Run:

    cst mycomd myclassname --action mymethod

Clone this wiki locally