Skip to main content

A Cli flags libary to control argv flags and content

Project description

Install from pip

linux: pip3 install cli-args-system
windows: pip install cli-args-system

Install from scratch

linux: sudo python3 setup.py install
windows: python setup.py install

What is cli_args_system ?

In an general way its a library to manipulate argv args its content and its flags

Basic Usage

the most basic application:

from cli_args_system import Args

args = Args()
print(args)
running:
$ python3  test.py  -a "value of a" -b "value of b"
results:

{
    "default": [],
    "a": [
        "value of a "
    ],
    "b": [
        "value of b"
    ]
}

Args:

retrieving the args:

from cli_args_system import Args

args = Args()

list_of_args = args.args()
print(list_of_args)
accessing args index:

from cli_args_system import Args

args = Args()

try:
    print(f'second arg is {args[1]}')
except IndexError:
    print('there less than 2 args')
making iterations:

from cli_args_system import Args

args = Args()

for a in args:
    print(a)

Flags:

retrieving all flags dict:

from cli_args_system import Args

args = Args()

flags = args.flags_dict()
print(flags)
running:

 python3 test.py 0 0x   -a 10 1a -b 20 1b 
 -> {'default': [0, '0x'], 'a': ['10', '1a'], 'b': [20, '1b']}
getting FlagsContent Object:

from cli_args_system import Args

args = Args()
out = args.flags_content('o','out')
print(out)
running:

python3 test.py -o a.txt
 -> 
exist:  True
filled: True
args:   ['a.txt']
retrieving flags and making iterations:

from cli_args_system import Args

args = Args()
out = args.flags_content('o','out')

full_list = out.flags()

try:
    first_element = out[0]
    print(f'first element is: {first_element}')
except IndexError:pass 

#making iterations
for f in out:
    print(f)

print(f'full list is: {full_list}')
running:

python3 test.py -o a.txt b.txt
 -> 
first element is: a.txt
a.txt
b.txt
full list is: ['a.txt', 'b.txt']
checking Flags Status:

from cli_args_system import Args

args = Args()
out = args.flags_content('o','out')

if out.exist():
    print('out flag exist')

if out.exist_and_empty():
    print('out flag exist but its empty')

if out.filled():
    print('out flag its filled')

if 'a.txt' in out:
    print('a.txt in out flag')
running:

python3 test.py -o a.txt
->
out flag exist
out flag its filled
a.txt in out flag

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

cli-args-system-1.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

cli_args_system-1.3-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file cli-args-system-1.3.tar.gz.

File metadata

  • Download URL: cli-args-system-1.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.6.0 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9

File hashes

Hashes for cli-args-system-1.3.tar.gz
Algorithm Hash digest
SHA256 a76048f0f6e5bdcc71b8c28afe6a149252774ee018c213ea7f34769aa5d619c6
MD5 0f1441fae9ff0bca593ba0ed6527dbc5
BLAKE2b-256 4671cc0f09ea8f9ee51b3304dff0ffb8e929cffbf6aa218cac50f9e0b3e85222

See more details on using hashes here.

File details

Details for the file cli_args_system-1.3-py3-none-any.whl.

File metadata

  • Download URL: cli_args_system-1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.6.0 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9

File hashes

Hashes for cli_args_system-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 08427802ca7acee8ae602c77d75d95ca9a86c7d5e08e4eec5719ca5403c64263
MD5 4f4656d1ecbb0caa046990102ff1dd8b
BLAKE2b-256 063c2e07655b9f8679f6823f677836e8f343a91c3632035dc190b78ec16c56c6

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