import os
import sys
import logging
import getopt
import inspect
def currentline():
"""Return the frame object for the caller's stack frame."""
try:
raise Exception
except:
return sys.exc_info()[2].tb_frame.f_back.f_lineno
def cmd_input(argv):
shortopts = 'hd:s:p:k:m:c:t:vqa'
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'workers=',
'forbidden-ip=', 'user=', 'manager-address=', 'version',
'prefer-ipv6']
try:
optlist, args = getopt.getopt(argv, shortopts, longopts)
for key , value in optlist:
if key == '-p':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-k':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-l':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-s':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-m':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-b':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-v':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-a':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-t':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--fast-open':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--workers':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--manager-address':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--user':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--forbidden-ip':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key in ('-h', '--help'):
usage()
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--version':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-d':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--pid-file':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--log-file':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '-q':
print ("%d is ---- %s==%s"%(currentline(),key,value))
elif key == '--prefer-ipv6':
print ("%d is ---- %s==%s"%(currentline(),key,value))
except getopt.GetoptError as e:
print("Error occur")
sys.exit(2)
def usage():
print('''usage: sslocal [OPTION]...
A fast tunnel proxy that helps you bypass firewalls.
You can supply configurations via either config file or command line arguments.
Proxy options:
-c CONFIG path to config file
-s SERVER_ADDR server address
-p SERVER_PORT server port, default: 8388
-b LOCAL_ADDR local binding address, default: 127.0.0.1
-l LOCAL_PORT local port, default: 1080
-k PASSWORD password
-m METHOD encryption method, default: aes-256-cfb
-t TIMEOUT timeout in seconds, default: 300
-a ONE_TIME_AUTH one time auth
--fast-open use TCP_FASTOPEN, requires Linux 3.7+
General options:
-h, --help show this help message and exit
-d start/stop/restart daemon mode
--pid-file PID_FILE pid file for daemon mode
--log-file LOG_FILE log file for daemon mode
--user USER username to run as
-v, -vv verbose mode
-q, -qq quiet mode, only show warnings/errors
--version show version information
''')
if __name__=="__main__":
cmd_input(sys.argv[1:])
Python cmd 模板
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...