CLI Argument Parser
Project description
SysArg
CLI Argument Parser Functions
Contents
- Install
- Initialize
- Functions
- defind : Setup option/command/group/help....
- Cmd : Get Inputed Special Command (it need cmd_id=1 parameter at initialize)
- Get : Get parameter's input values
- Version : show version
- Check : Check option
- Help : Dispaly Help
- Install
pip install SysArg
- Initialize
- program : Program Name
- cmd_id : command ID
- desc : Program Description
- epilog : Program Epilog (tail string of the help)
- version : define Program version
- help_desc: Customize description of Help
import SysArg
arg=SysArg.SysArg(program='ArgTest',desc='ARG. Testing',version='1.0')
if you want make a special command in this application case: (ArgTest command ...)
import SysArg
arg=SysArg.SysArg(program='ArgTest',desc='ARG. Testing',version='1.0',cmd_id=1)
- defind
- name: (required) parameter name
- short: short parameter(-XX)
- long: long parameter(--XX)
- params:
- default:0(found parameter then True),
- 0<n: how many required parameter input data(number)
- - : until next parameter or until finished inputs
- params_name: --abc=<PARAMS_NAME(Explain String)> (this format)
- required: required parameter (default False, need then True)
- default: default value when no input
- type: default str, wrong type then not taken (support: str,int,list,tuple,dict)
- spliter: if you set list or tuple at type. but input is single string then using spliter (example: , : )
- group: make a special group's prameters
- group_desc: group desciption
- command: If Command Group then True
example format: -n, --numbre=INT
arg.define('number',short='-n',long='--number',params_name='INT',type=int,desc='Number Input')
it this option required value
arg.define('number',short='-n',long='--number',params_name='INT',type=int,desc='Number Input',required=True)
Add some of GROUP(ex: INPUT)
arg.define('number',short='-n',long='--number',params_name='INT',type=int,desc='Number Input',group='INPUT')
example format: -n, --numbre INT
arg.define('number',short='-n',long='--number',params=1,type=int,desc='Number Input')
example format: -l, --list ['A','B']
arg.define('List',short='-l',long='--list',params=1,type=list,desc='List Input')
example format: -l, --list 'A,B,C'
arg.define('List',short='-l',long='--list',params=1,type=list,spliter=',',desc='List Input')
example format: -l, --list A B C
arg.define('List',short='-l',long='--list',params=3,type=list,desc='List Input')
example default : if not input then default get 7
arg.define('N',short='-n',long='--number',params=1,type=int,desc='Number Input',default=7)
example check parameter: if -n or --number parameter then True
arg.define('N',short='-n',long='--number')
example command group:
arg.define(group_desc='File list',group='ls',command=True)
arg.define('show_detail',short='-l',desc='show detail',group='ls')
arg.define('show_time',short='-t',desc='show time',group='ls')
- Cmd Get Input Command name
cmd=arg.Cmd()
- Get parameter's value
- All data
param=arg.Get()
- Get group INPUT's All data
param=arg.Get(group='INPUT')
- Get Parameter number's data
param=arg.Get('number')
- Get Parameter List's data in the INPUT group
param=arg.Get('List',group='INPUT')
Simple Example)
import SysArg
arg=SysArg.SysArg(program='ArgTest',desc='ARG. Testing',version='1.0',cmd_id=1)
arg.define('a',short='-a',long='--abc',desc='test input',params=1)
arg.Version()
arg.Help()
cmd=arg.Cmd()
a=arg.Get('a')
Project details
Release history Release notifications | RSS feed
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 SysArg-1.1.16.tar.gz.
File metadata
- Download URL: SysArg-1.1.16.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7a90c017d3d2f47850fe568826c42bd1ecd769715569eb4215fe6948c46b088
|
|
| MD5 |
c1bc20523e9c1d9193aacd636bc56e2a
|
|
| BLAKE2b-256 |
16769004c08308be67b92b1d2eac193bcf0dae31cc717e1eafa86768365a702d
|
File details
Details for the file SysArg-1.1.16-py3-none-any.whl.
File metadata
- Download URL: SysArg-1.1.16-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93f86e806b88bd7023239d54b2463b564f33d8486a5fc80942aad9a39d6d1f48
|
|
| MD5 |
9642d5c095493e761bf8b3353fe2a98e
|
|
| BLAKE2b-256 |
6f902c4add8005b1724c81c4794bf02122c4eee2e956ae46f7ae7a0f5c175f42
|