Socket
Socket
Sign inDemoInstall

cli-args

Package Overview
Dependencies
1
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cli-args

Command line arguments. Made simple.


Maintainers
1

Readme

cli-args

Do you belong to those who have to look up the calls you have to make to argparse? And are you longing for a way to just import the parsed arguments as you would import sys.argv? Then cli-args is the way to go!

cli-args is a Python library for an easier parsing of command line arguments. It wraps the popular argparse to allow importing parsed arguments from anywhere in the code. One of the key features is the way you define what arguments you accept. By providing a dictionary - that also can be read from a JSON file! - you can easily set all available command line arguments at one specific, easy-to-find place.

Get it!

pip install cli-args

Use it!

demo.py

import cli_args


# or: cli_args.from_file('path/to/schema.json')
cli_args.from_schema({
    "description": "Process some integers.",
    "arguments": [
        {
            "short": "a",
            "long": "integer_a",
            "var": "NUMBER",
            "help": "The first integer",
            "default": 0,
            "type": "int"
        },
        {
            "short": "b",
            "long": "integer_b",
            "var": "NUMBER",
            "help": "The second integer",
            "default": "0",
            "type": "int"
        }
    ]
})


print(cli_args.argv['integer_a']) # 3
print(cli_args.argv['integer_b']) # 5

python demo.py --integer_a=3 --integer_b=5

License

Licensed under the MIT License. Happy forking :)

FAQs


Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc