printrun-src/pronsole.py

changeset 45
c82943fb205f
parent 15
0bbb006204fc
equal deleted inserted replaced
44:310be640a303 45:c82943fb205f
1 #!/usr/bin/env python 1 #!/usr/bin/env python3
2 2
3 # This file is part of the Printrun suite. 3 # This file is part of the Printrun suite.
4 # 4 #
5 # Printrun is free software: you can redistribute it and/or modify 5 # Printrun is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
24 if __name__ == "__main__": 24 if __name__ == "__main__":
25 25
26 from printrun.printcore import __version__ as printcore_version 26 from printrun.printcore import __version__ as printcore_version
27 27
28 usage = "Usage:\n"+\ 28 usage = "Usage:\n"+\
29 " pronsole [OPTION]\n\n"+\ 29 " pronsole [OPTIONS] [FILE]\n\n"+\
30 "Options:\n"+\ 30 "Options:\n"+\
31 " -h, --help\t\t\tPrint this help message and exit\n"+\
31 " -V, --version\t\t\tPrint program's version number and exit\n"+\ 32 " -V, --version\t\t\tPrint program's version number and exit\n"+\
32 " -h, --help\t\t\tPrint this help message and exit\n"+\ 33 " -v, --verbose\t\t\tIncrease verbosity\n"+\
33 " -c, --conf\t\t\tLoad this file on startup instead of .pronsolerc; you may chain config files, if so settings auto-save will use the last specified file\n"+\ 34 " -c, --conf, --config=CONFIG_FILE\tLoad this file on startup instead of .pronsolerc; you may chain config files, if so settings auto-save will use the last specified file\n"+\
34 " -e, --execute\t\t\tExecutes command after configuration/.pronsolerc is loaded; macros/settings from these commands are not autosaved" 35 " -e, --execute=COMMAND\t\tExecutes command after configuration/.pronsolerc is loaded; macros/settings from these commands are not autosaved"
35 36
36 try: 37 try:
37 opts, args = getopt.getopt(sys.argv[1:], "hVce", ["help", "version", "conf", "execute"]) 38 opts, args = getopt.getopt(sys.argv[1:], "hVvc:e:", ["help", "version", "verbose", "conf=", "config=", "execute="])
38 except getopt.GetoptError, err: 39 except getopt.GetoptError as err:
39 print str(err) 40 print(str(err))
40 print usage 41 print(usage)
41 sys.exit(2) 42 sys.exit(2)
42 for o, a in opts: 43 for o, a in opts:
43 if o in ('-V','--version'): 44 if o in ('-V','--version'):
44 print "printrun "+printcore_version 45 print("printrun "+printcore_version)
45 sys.exit(0) 46 sys.exit(0)
46 elif o in ('-h', '--help'): 47 elif o in ('-h', '--help'):
47 print usage 48 print(usage)
48 sys.exit(0) 49 sys.exit(0)
49 50
50 interp = pronsole() 51 interp = pronsole()
51 interp.parse_cmdline(sys.argv[1:]) 52 interp.parse_cmdline(sys.argv[1:])
52 try: 53 try:

mercurial