sys.exit(MSG)
This commit is contained in:
parent
2a83769797
commit
134bdf68df
@ -4,10 +4,12 @@ import sys
|
|||||||
try:
|
try:
|
||||||
import curses
|
import curses
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("This program requires curses.")
|
sys.exit(
|
||||||
print("You can install it on Windows with:")
|
"""This program requires curses.
|
||||||
print("pip install --user windows-curses")
|
You can install it on Windows with:
|
||||||
sys.exit(1)
|
pip install --user windows-curses
|
||||||
|
"""
|
||||||
|
)
|
||||||
import random
|
import random
|
||||||
import sched
|
import sched
|
||||||
import time
|
import time
|
||||||
@ -22,6 +24,15 @@ except ImportError:
|
|||||||
|
|
||||||
DIR_NAME = "Terminis"
|
DIR_NAME = "Terminis"
|
||||||
|
|
||||||
|
HELP_MSG = """terminis [--edit|--help|n]
|
||||||
|
|
||||||
|
Tetris clone for terminal
|
||||||
|
|
||||||
|
--edit: edit controls in text editor
|
||||||
|
--help: show command usage (this message)
|
||||||
|
n (integer between 1 and 15): start at level n
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
if locale.getpreferredencoding() == 'UTF-8':
|
if locale.getpreferredencoding() == 'UTF-8':
|
||||||
@ -378,8 +389,7 @@ class Stats(Window):
|
|||||||
try:
|
try:
|
||||||
self.level = int(sys.argv[1])
|
self.level = int(sys.argv[1])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print_help()
|
sys.exit(HELP_MSG)
|
||||||
sys.exit(1)
|
|
||||||
else:
|
else:
|
||||||
self.level = max(1, self.level)
|
self.level = max(1, self.level)
|
||||||
self.level = min(15, self.level)
|
self.level = min(15, self.level)
|
||||||
@ -722,7 +732,7 @@ def main():
|
|||||||
if "--edit" in sys.argv[1:]:
|
if "--edit" in sys.argv[1:]:
|
||||||
edit()
|
edit()
|
||||||
elif "--help" in sys.argv[1:] or "/?" in sys.argv[1:]:
|
elif "--help" in sys.argv[1:] or "/?" in sys.argv[1:]:
|
||||||
print_help()
|
print(HELP_MSG)
|
||||||
else:
|
else:
|
||||||
curses.wrapper(Game)
|
curses.wrapper(Game)
|
||||||
|
|
||||||
@ -735,17 +745,6 @@ def edit():
|
|||||||
else:
|
else:
|
||||||
subprocess.call(["${EDITOR:-vi}", Controls.FILE_PATH])
|
subprocess.call(["${EDITOR:-vi}", Controls.FILE_PATH])
|
||||||
|
|
||||||
def print_help():
|
|
||||||
print(
|
|
||||||
"""terminis [--edit|--help|n]
|
|
||||||
|
|
||||||
Tetris clone for terminal
|
|
||||||
|
|
||||||
--edit: edit controls in text editor
|
|
||||||
--help: show command usage (this message)
|
|
||||||
n (integer between 1 and 15): start at level n
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user