Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use getopts to parse command line args #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions hsandbox
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import sys
import time
import os
import re
import getopt

try:
import pyinotify
Expand Down Expand Up @@ -492,18 +493,22 @@ def main(argv):
mode = "screen"
vertical = False

if len(argv) > 2:
for option in argv[2:]:
if option == "--editor":
mode = "editor"
elif option == "--runner":
mode = "runner"
elif option == "-c":
hacking.use_old_sandbox = True
elif option == "-v":
vertical = True
else:
sys.exit(USAGE)
try:
opts, args = getopt.getopt(argv[2:], "cv", ["editor", "runner"])
except getopt.GetoptError as err:
sys.exit(USAGE)

for opt, a in opts:
if opt in "--editor":
mode = "editor"
elif opt in "--runner":
mode = "runner"
elif opt == "-c":
hacking.use_old_sandbox = True
elif opt == "-v":
vertical = True
else:
sys.exit(USAGE)

if mode == "screen":
screen(hacking, argv, vertical)
Expand Down