🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

cli-args-system

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-args-system

A Cli flags libary to control argv flags and content

1.3
PyPI
Maintainers
1

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

Keywords

ARGV

FAQs

Did you know?

Socket

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