Skip to main content

Simple tool to parse shell arguments using eval

Project description

ShellArgParser

A simple python tool to parse any arg / kwarg arguments in a manner that is easy to parse for the linux shell.

I don't understand

For example:

./shell_arg_parser.sh --test=something -a -b -no-c

Will print this text:

ARGS_A=1
ARGS_B=1
ARGS_C=0
ARGS_TEST="something"

So running this:

eval $(./shell_arg_parser.sh --test=something -a -b -no-c)

Will parse the args and kwargs as environment variables, handy for use in the shell:

echo $ARGS_TEST  # outputs 'something'

Notes:

  • -something is parsed as ARGS_SOMETHING=1
  • -no-something is parsed as ARGS_SOMETHING=0
  • -no_something is parsed as ARGS_SOMETHING=0
  • Any None python value is parsed as 0
  • A prototype 'pure shell' version of this script can be found in ./ShellArgParser.sh

Getting started

  • From pypi:
    • As a tool: uvx ShellArgParser@latest --help
    • Via uv: uv pip install ShellArgParser
    • Via pip: pip install ShellArgParser
  • From github:
    • Clone this repo then pip install .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shellargparser-0.0.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ShellArgParser-0.0.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file shellargparser-0.0.1.tar.gz.

File metadata

  • Download URL: shellargparser-0.0.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.20

File hashes

Hashes for shellargparser-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6c9b00aaab6fc9ef1b6d8481e03b4328702f50d5498b90a14de02750e519bdbc
MD5 3b06acf88452575c090704b16207c295
BLAKE2b-256 df2305dd5d0abc56053b969b3190a393904781fa2e587aa6ab22eda9fde43109

See more details on using hashes here.

File details

Details for the file ShellArgParser-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ShellArgParser-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.20

File hashes

Hashes for ShellArgParser-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d453e23fdc06bf22c1491e2a3ce7d970faa9f14665c54b90ab8546f63a18216
MD5 8fe26c064cc936108313e0cc3652834a
BLAKE2b-256 9ba119f854ba80898c25b2d19addd69f5910ac930746efed00b5c9f63f258f1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page