New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

argshell

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argshell

Integrates the argparse and cmd modules.

  • 1.6.5
  • PyPI
  • Socket score

Maintainers
1

argshell

Integrates the argparse and cmd modules to create custom shells with argparse functionality.

Installation

Install with:

pip install argshell

Usage

Custom shells are created by subclassing the ArgShell class and adding functions of the form do_*(), just like the cmd.Cmd class.
The ArgShell class contains a rich.console.Console object that can be used to print renderables.

In terminal:


Rather than being limited to input strings, you can use argparse style parsers for shell commands.
Create a function that instantiates an ArgShellParser instance, adds arguments, and then returns the ArgShellParser object.
Then you can can decorate do_* functions using with_parser() to pass a Namespace object instead of a string.

In terminal:


The with_parser function also accepts an optional list of functions that accept and return an argshell.Namespace object.
These functions will be executed in order after the parser function parses the arguments.

In terminal:


When using your shell, entering help command will, in addition to the command's doc string, print the help message of the parser that decorates it, if it is decorated.


The capture command can be used to save an svg of another command's output by prepending to a command.
(NOTE: This only works for output printed with ArgShell's console member mentioned earlier.)
The font size is proportional to your terminal width when using the command and any text your terminal wraps will be truncated in the svg.
The following would create a file called add.svg in your current directory: The saved svg:


There's also a "hidden" command for generating documentation called shell_docs.

Executing that command for MyShell:

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc