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:

uvx ShellArgParser@latest --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 $(uvx ShellArgParser@latest --test=something -a -b -no-c)

Will parse the args and kwargs as shell 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 uv 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.2.0.tar.gz (15.0 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.2.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for shellargparser-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2b92c41d5a06effa3b20ad34e3d3cb16bdf691c6b69cfda23991861a6bce24bb
MD5 1ea47abc5257141036ca563a95f2295d
BLAKE2b-256 5ea521a4860cab1767a8b2a0d8db5e43eb53d6157f6dbb20ac3203a8a86a180c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ShellArgParser-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7199a94010290edb1819ce93f1bef504f9581115530ef45e4e943707fa7229b2
MD5 20567fa6057708518c9ae12d4a7918bb
BLAKE2b-256 f1d2170c12ba4d5b457db0bb206223cac536e3b00516bef49ca23650034e9085

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