Compare commits
2 Commits
88a5898f8c
...
1931445c13
Author | SHA1 | Date | |
---|---|---|---|
1931445c13 | |||
816b07306f |
178
old/utool.py
Executable file
178
old/utool.py
Executable file
@ -0,0 +1,178 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# coding: utf-8
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
c_title = '\033[1;4;31;42m' # title color
|
||||||
|
c_br = '\033[1;31m' # bold red
|
||||||
|
c_bg = '\033[1;32m' # bold green
|
||||||
|
c_by = '\033[1;33m' # bold yellow
|
||||||
|
c_bb = '\033[1;34m' # bold blue
|
||||||
|
c_bp = '\033[1;35m' # bold purple
|
||||||
|
c_bc = '\033[1;36m' # bold cyan
|
||||||
|
c_bir= '\033[1;3;31m' # * bold italic red
|
||||||
|
c_bib = '\033[1;3;34m' # * bold italic cyan
|
||||||
|
c_bic = '\033[1;3;36m' # bold italic cyan
|
||||||
|
c_e = '\033[0m' # reset
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
opt_1 = sys.argv[1]
|
||||||
|
opt_rest = None
|
||||||
|
elif len(sys.argv) > 2:
|
||||||
|
opt_1 = sys.argv[1]
|
||||||
|
opt_rest = sys.argv[2:]
|
||||||
|
else:
|
||||||
|
opt_1 = None
|
||||||
|
opt_rest = None
|
||||||
|
|
||||||
|
opt_index = ['-do_not_use_this', '-a', '-b', '-c', '-d', '-e', '-f', '-g', '-h', '-i', '-j', '-k', '-l', '-m',
|
||||||
|
'-n', '-o', '-p', '-q', '-r', '-s', '-t', '-u', '-v', '-w', '-x', '-y', '-z']
|
||||||
|
|
||||||
|
if opt_1 not in opt_index:
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
||||||
|
exit(100)
|
||||||
|
|
||||||
|
if opt_1 == '-a':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will print all ports of now using for local, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
|
||||||
|
|
||||||
|
elif opt_1 == '-b':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will generate a two-factor auth-key for github login, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system("/usr/bin/oathtool -b --totp 'G3NHHFO2L2LZ5W2R'")
|
||||||
|
|
||||||
|
elif opt_1 == '-c':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will print all intranet IP using in docker, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh ip')
|
||||||
|
|
||||||
|
elif opt_1 == '-d':
|
||||||
|
if opt_rest != None:
|
||||||
|
print(f"This option({opt_1}) will return the current IP of local machine, and accept NO parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
|
||||||
|
|
||||||
|
elif opt_1 == '-e':
|
||||||
|
if opt_rest == None:
|
||||||
|
print(f"This option({opt_1}) will return the IP info, and accept at least one IP parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
for opt_2 in opt_rest:
|
||||||
|
os.environ['opt_2'] = opt_2
|
||||||
|
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $opt_2')
|
||||||
|
|
||||||
|
elif opt_1 == '-f':
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print(f"{c_br}需要至少一个字符串作为输入,退出...{c_e}\n")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
param=''
|
||||||
|
for item in sys.argv[2:]:
|
||||||
|
param += item
|
||||||
|
|
||||||
|
os.environ['param'] = param
|
||||||
|
print(f"{c_by}Warning: 输入字符串中间的任何空白符将会被删除,要保留的话,需手动将字符串用单引号括起来{c_e}")
|
||||||
|
print(f"本次计算MD5值的字符串为 - {param}\n本次计算得到的MD5的值为 - ", end='')
|
||||||
|
# print(f"本次计算得到的MD5的值为 - ", end='')
|
||||||
|
os.system('echo -n $param | md5sum | cut -d " " -f 1')
|
||||||
|
|
||||||
|
elif opt_1 == '-g':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-h':
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-i':
|
||||||
|
if opt_rest == None:
|
||||||
|
print(f"This option({opt_1}) will return the domain registration info, and accept at least one domain parameter.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
for opt_2 in opt_rest:
|
||||||
|
os.environ['opt_2'] = opt_2
|
||||||
|
os.system('/usr/bin/python3 /opt/scripts/roll_api/domain_reg_check.py $opt_2')
|
||||||
|
|
||||||
|
elif opt_1 == '-j':
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
print(f"{c_br}-j选项:将十进制或者十六进制数字作为入参,转换成标准时间格式,只接收第一个参数,其他参数将被丢弃,有歧义时,使用'0x'或者'0X'来区分十进制和十六进制,退出...{c_e}\n")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
os.environ['param'] = sys.argv[2]
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/number2d.sh $param')
|
||||||
|
|
||||||
|
elif opt_1 == '-k':
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print(f"{c_br}-k选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
|
||||||
|
param=''
|
||||||
|
for item in sys.argv[2:]:
|
||||||
|
param += item + ' '
|
||||||
|
|
||||||
|
os.environ['param'] = param
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/date2n.sh $param')
|
||||||
|
|
||||||
|
elif opt_1 == '-l':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-m':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-n':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-o':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-p':
|
||||||
|
if opt_rest == None:
|
||||||
|
opt_rest = ['',]
|
||||||
|
|
||||||
|
opt_2 = opt_rest[0]
|
||||||
|
os.environ['opt_2'] = opt_2
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/genpw.sh $opt_2')
|
||||||
|
|
||||||
|
elif opt_1 == '-q':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-r':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-s':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-t':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-u':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-v':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-w':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-x':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-y':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
elif opt_1 == '-z':
|
||||||
|
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
||||||
|
exit(opt_index.index(opt_1))
|
||||||
|
else:
|
||||||
|
print("This line SHOULD NOT be executed, please check carefully.")
|
||||||
|
exit(255)
|
||||||
|
|
||||||
|
|
||||||
|
|
272
utool/utool.py
272
utool/utool.py
@ -4,175 +4,125 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
c_title = '\033[1;4;31;42m' # title color
|
def utool(option):
|
||||||
c_br = '\033[1;31m' # bold red
|
|
||||||
c_bg = '\033[1;32m' # bold green
|
|
||||||
c_by = '\033[1;33m' # bold yellow
|
|
||||||
c_bb = '\033[1;34m' # bold blue
|
|
||||||
c_bp = '\033[1;35m' # bold purple
|
|
||||||
c_bc = '\033[1;36m' # bold cyan
|
|
||||||
c_bir= '\033[1;3;31m' # * bold italic red
|
|
||||||
c_bib = '\033[1;3;34m' # * bold italic cyan
|
|
||||||
c_bic = '\033[1;3;36m' # bold italic cyan
|
|
||||||
c_e = '\033[0m' # reset
|
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
def print_usage():
|
||||||
opt_1 = sys.argv[1]
|
intro = """utool -- a self-defined command line interface, which is used to facilitate operating the system, supports the following options. In the description part, where there is a leading asterisk signifies that this option must take an argument, and for more information of this situation, simply run `utool -h` for details."""
|
||||||
opt_rest = None
|
print(f"{c_intro}{intro}{c_e}")
|
||||||
elif len(sys.argv) > 2:
|
print("_" * 121)
|
||||||
opt_1 = sys.argv[1]
|
print(f"{c_title}|Option| Description{' ' * 40}|Option| Description{' ' * 40}|{c_e}")
|
||||||
opt_rest = sys.argv[2:]
|
count = 0
|
||||||
else:
|
for opt, desc in dict_func.items():
|
||||||
opt_1 = None
|
description = "" if desc[0] == "Reserved" else desc[0]
|
||||||
opt_rest = None
|
if count % 2 == 0:
|
||||||
|
print(f"{c_text}|{opt:^6}|{description:<52}{c_e}", end="")
|
||||||
|
else:
|
||||||
|
print(f"{c_text}|{opt:^6}|{description:<52}|{c_e}")
|
||||||
|
count += 1
|
||||||
|
exit(100)
|
||||||
|
|
||||||
opt_index = ['-do_not_use_this', '-a', '-b', '-c', '-d', '-e', '-f', '-g', '-h', '-i', '-j', '-k', '-l', '-m',
|
# -a
|
||||||
'-n', '-o', '-p', '-q', '-r', '-s', '-t', '-u', '-v', '-w', '-x', '-y', '-z']
|
def list_local_using_port():
|
||||||
|
exit_on_wrong_number()
|
||||||
|
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
|
||||||
|
|
||||||
if opt_1 not in opt_index:
|
# -b
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
def github_two_factor():
|
||||||
exit(100)
|
exit_on_wrong_number()
|
||||||
|
os.system("/usr/bin/oathtool -b --totp 'G3NHHFO2L2LZ5W2R'")
|
||||||
|
|
||||||
if opt_1 == '-a':
|
# -c
|
||||||
if opt_rest != None:
|
def get_external_ip():
|
||||||
print(f"This option({opt_1}) will print all ports of now using for local, and accept NO parameter.")
|
exit_on_wrong_number()
|
||||||
exit(opt_index.index(opt_1))
|
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
|
||||||
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
|
# -d
|
||||||
|
def get_ip_location():
|
||||||
|
exit_on_wrong_number(2)
|
||||||
|
import re
|
||||||
|
checked_ip = sys.argv[2]
|
||||||
|
ipv4 = re.match(r"^((([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))\.){3}(([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))$", checked_ip)
|
||||||
|
if ipv4:
|
||||||
|
os.environ['checked_ip'] = checked_ip
|
||||||
|
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $checked_ip')
|
||||||
|
else:
|
||||||
|
print(f"{c_br}Plz enter correct IP...{c_e}")
|
||||||
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
elif opt_1 == '-b':
|
|
||||||
if opt_rest != None:
|
|
||||||
print(f"This option({opt_1}) will generate a two-factor auth-key for github login, and accept NO parameter.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
|
|
||||||
os.system("/usr/bin/oathtool -b --totp 'G3NHHFO2L2LZ5W2R'")
|
def exit_on_wrong_number(number=1):
|
||||||
|
if len(sys.argv) != (number+1):
|
||||||
|
print(f"{c_br}{sys.argv[1:]}: Wrong arguments!")
|
||||||
|
print(f"Option `{option}' will {dict_func[option][0].strip()}")
|
||||||
|
print(f"NEED: {number}\tGIVE: {len(sys.argv)-1}\n{c_e}")
|
||||||
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
elif opt_1 == '-c':
|
dict_func = {
|
||||||
if opt_rest != None:
|
'-a': [' print all local ports of using for now', list_local_using_port],
|
||||||
print(f"This option({opt_1}) will print all intranet IP using in docker, and accept NO parameter.")
|
'-n': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-b': [' generate two-factor key of GITHUB', github_two_factor],
|
||||||
|
'-o': ['Reserved', None],
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh ip')
|
'-c': [' show external IP of this machine', get_external_ip],
|
||||||
|
'-p': ['Reserved', None],
|
||||||
elif opt_1 == '-d':
|
'-d': [' show the location of ip(only v4 for now)', get_ip_location],
|
||||||
if opt_rest != None:
|
'-q': ['Reserved', None],
|
||||||
print(f"This option({opt_1}) will return the current IP of local machine, and accept NO parameter.")
|
'-e': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-r': ['Reserved', None],
|
||||||
|
'-f': ['Reserved', None],
|
||||||
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
|
'-s': ['Reserved', None],
|
||||||
|
'-g': ['Reserved', None],
|
||||||
elif opt_1 == '-e':
|
'-t': ['Reserved', None],
|
||||||
if opt_rest == None:
|
'-h': ['Reserved', print_usage],
|
||||||
print(f"This option({opt_1}) will return the IP info, and accept at least one IP parameter.")
|
'-u': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-i': ['Reserved', None],
|
||||||
|
'-v': ['Reserved', None],
|
||||||
for opt_2 in opt_rest:
|
'-j': ['Reserved', None],
|
||||||
os.environ['opt_2'] = opt_2
|
'-w': ['Reserved', None],
|
||||||
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $opt_2')
|
'-k': ['Reserved', None],
|
||||||
|
'-x': ['Reserved', None],
|
||||||
elif opt_1 == '-f':
|
'-l': ['Reserved', None],
|
||||||
if len(sys.argv) < 3:
|
'-y': ['Reserved', None],
|
||||||
print(f"{c_br}需要至少一个字符串作为输入,退出...{c_e}\n")
|
'-m': ['Reserved', None],
|
||||||
exit(opt_index.index(opt_1))
|
'-z': ['Reserved', None],
|
||||||
|
}
|
||||||
param=''
|
return dict_func[option][1]
|
||||||
for item in sys.argv[2:]:
|
|
||||||
param += item
|
|
||||||
|
|
||||||
os.environ['param'] = param
|
|
||||||
print(f"{c_by}Warning: 输入字符串中间的任何空白符将会被删除,要保留的话,需手动将字符串用单引号括起来{c_e}")
|
|
||||||
print(f"本次计算MD5值的字符串为 - {param}\n本次计算得到的MD5的值为 - ", end='')
|
|
||||||
# print(f"本次计算得到的MD5的值为 - ", end='')
|
|
||||||
os.system('echo -n $param | md5sum | cut -d " " -f 1')
|
|
||||||
|
|
||||||
elif opt_1 == '-g':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-h':
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/usage.sh')
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-i':
|
|
||||||
if opt_rest == None:
|
|
||||||
print(f"This option({opt_1}) will return the domain registration info, and accept at least one domain parameter.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
|
|
||||||
for opt_2 in opt_rest:
|
|
||||||
os.environ['opt_2'] = opt_2
|
|
||||||
os.system('/usr/bin/python3 /opt/scripts/roll_api/domain_reg_check.py $opt_2')
|
|
||||||
|
|
||||||
elif opt_1 == '-j':
|
|
||||||
if len(sys.argv) == 2:
|
|
||||||
print(f"{c_br}-j选项:将十进制或者十六进制数字作为入参,转换成标准时间格式,只接收第一个参数,其他参数将被丢弃,有歧义时,使用'0x'或者'0X'来区分十进制和十六进制,退出...{c_e}\n")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
|
|
||||||
os.environ['param'] = sys.argv[2]
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/number2d.sh $param')
|
|
||||||
|
|
||||||
elif opt_1 == '-k':
|
|
||||||
if len(sys.argv) < 3:
|
|
||||||
print(f"{c_br}-k选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
|
|
||||||
param=''
|
|
||||||
for item in sys.argv[2:]:
|
|
||||||
param += item + ' '
|
|
||||||
|
|
||||||
os.environ['param'] = param
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/date2n.sh $param')
|
|
||||||
|
|
||||||
elif opt_1 == '-l':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-m':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-n':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-o':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-p':
|
|
||||||
if opt_rest == None:
|
|
||||||
opt_rest = ['',]
|
|
||||||
|
|
||||||
opt_2 = opt_rest[0]
|
|
||||||
os.environ['opt_2'] = opt_2
|
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/genpw.sh $opt_2')
|
|
||||||
|
|
||||||
elif opt_1 == '-q':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-r':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-s':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-t':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-u':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-v':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-w':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-x':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-y':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
elif opt_1 == '-z':
|
|
||||||
print(f"This option({opt_1}) is reserved now, nothing is bound on it.")
|
|
||||||
exit(opt_index.index(opt_1))
|
|
||||||
else:
|
|
||||||
print("This line SHOULD NOT be executed, please check carefully.")
|
|
||||||
exit(255)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
global option
|
||||||
|
options = [ '-' + chr(x) for x in range(ord('a'), ord('z')+1)]
|
||||||
|
print_usage = utool('-h')
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
option = sys.argv[1]
|
||||||
|
if option in options:
|
||||||
|
func = utool(option)
|
||||||
|
if func == None:
|
||||||
|
print(f"{c_bg}Option `{option}' is reserved for now...{c_e}\n")
|
||||||
|
else:
|
||||||
|
func()
|
||||||
|
else:
|
||||||
|
print_usage()
|
||||||
|
else:
|
||||||
|
print_usage()
|
||||||
|
|
||||||
|
c_title = '\033[1;4;37;40m' # title color
|
||||||
|
c_text = '\033[37;40m' # text color
|
||||||
|
c_intro = '\033[3;32m' # text color
|
||||||
|
c_br = '\033[1;31m' # bold red
|
||||||
|
c_bg = '\033[1;32m' # bold green
|
||||||
|
c_by = '\033[1;33m' # bold yellow
|
||||||
|
c_bb = '\033[1;34m' # bold blue
|
||||||
|
c_bp = '\033[1;35m' # bold purple
|
||||||
|
c_bc = '\033[1;36m' # bold cyan
|
||||||
|
c_bir= '\033[1;3;31m' # * bold italic red
|
||||||
|
c_bib = '\033[1;3;34m' # * bold italic cyan
|
||||||
|
c_bic = '\033[1;3;36m' # bold italic cyan
|
||||||
|
c_e = '\033[0m' # reset
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user