Skip to content

Commit

Permalink
Bug 729778: check for unknown commands before reading package.json. r=@…
Browse files Browse the repository at this point in the history
…MarkH

This allows mistyped commands like "cfx blah" to emit the useful (and
originally intended) "Unknown command, try --help" message. Some very old
refactoring (before release 0.1) caused the code that reads package.json to
be run too early, such that "cfx blah" emits "unable to find package.json"
instead of "Unknown command".
  • Loading branch information
warner committed Feb 29, 2012
1 parent e9eb864 commit b0ec3bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python-lib/cuddlefish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
filename = generate.generate_static_docs(env_root)
print >>stdout, "Wrote %s." % filename
return
elif command not in ["xpi", "test", "run"]:
print >>sys.stderr, "Unknown command: %s" % command
print >>sys.stderr, "Try using '--help' for assistance."
sys.exit(1)

target_cfg_json = None
if not target_cfg:
Expand Down Expand Up @@ -569,9 +573,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
elif command == "run":
use_main = True
else:
print >>sys.stderr, "Unknown command: %s" % command
print >>sys.stderr, "Try using '--help' for assistance."
sys.exit(1)
assert 0, "shouldn't get here"

if use_main and 'main' not in target_cfg:
# If the user supplies a template dir, then the main
Expand Down

0 comments on commit b0ec3bb

Please sign in to comment.