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 a_file --test=something -a -b -no-c another_file
Will print this text:
ARGS_1="a_file"
ARGS_2="another_file"
ARGS_TEST="something"
ARGS_A=1
ARGS_B=1
ARGS_C=0
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'
But why would you make this?
Handling user arguments are a major annoyance for me in shell, and in python using fire makes it a breeze, so it's is a great way to avoid reinventing the wheel.
Hence, when writing a small shell script, using a python cli tool oneliner makes is a real time saver for me.
Notes:
-somethingis parsed asARGS_SOMETHING=1-no-somethingis parsed asARGS_SOMETHING=0-no_somethingis parsed asARGS_SOMETHING=0- Any
Nonepython value is parsed as0 - 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
- As a uv tool:
- From github:
- Clone this repo then
pip install .
- Clone this repo then
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shellargparser-0.2.2.tar.gz.
File metadata
- Download URL: shellargparser-0.2.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eb9e76ce5cee3ea20a499e3e7e4351176b60c2a5425b4354617b37acac4b9da
|
|
| MD5 |
1074562b49cc0c6bd7431af515805a16
|
|
| BLAKE2b-256 |
270dd4340cd4d3e40c39f6b7f01548039c8151219000944a9bf28039c8fb352f
|
File details
Details for the file ShellArgParser-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ShellArgParser-0.2.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bace35f377bc374d64c27dd83aeaa1638555da65c8b4c3950cfbc04af6237b54
|
|
| MD5 |
1604cd1fd32183b17c9dff91bed58571
|
|
| BLAKE2b-256 |
6facf0b699746ef4cdbe1130e2d75ee0f98d0c682f6d734a1b7935f2d7bc4975
|