-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetargs.py
More file actions
50 lines (36 loc) · 1.84 KB
/
getargs.py
File metadata and controls
50 lines (36 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
import argparse
class GetArgs():
def __init__(self):
self.set_args_list()
def set_args_list(self):
py_des = '''\
----------------------------------------------------------------------------
remoteCLI: Remote cli command options.
----------------------------------------------------------------------------
'''
py_usage='''%(prog)s remoteCLI [options] / [-h/--help]'''
py_ver = '%(prog)s Experimental'
self.parser = argparse.ArgumentParser(prog="remoteCLI",
allow_abbrev=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description=py_des,
usage=py_usage,
epilog="For more information about each option, please see man remoteCLI.1 " +
"This program is distributed under GPL-2 license",
add_help=False)
self.parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS,
help='Show this help message and exit.')
subparsers = self.parser.add_subparsers(title='System Commands')
system_parser = subparsers.add_parser("system")
system_parser.add_argument("command",
help="System command",
choices=["ls","pwd","cwd"]
)
def check_args(self, args):
args = self.parser.parse_args(args)
args_dict = {}
for i in args.__dict__:
if args.__dict__[i] not in [False, None]:
args_dict[i] = args.__dict__[i]
return args_dict