Skip to content

Commit 094e770

Browse files
committed
print help when no command supplied to commands.py
1 parent 58cb13a commit 094e770

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

commands.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ def update_plotlyjs_dev(args, outdir):
296296
perform_codegen(outdir)
297297

298298

299-
def parse_args():
300-
"""Parse command-line arguments."""
299+
def make_parser():
300+
"""Make argument parser."""
301301

302302
parser = argparse.ArgumentParser()
303303
subparsers = parser.add_subparsers(dest="cmd", help="Available subcommands")
@@ -322,6 +322,10 @@ def parse_args():
322322

323323
subparsers.add_parser("updateplotlyjs", help="update plotly.js")
324324

325+
return parser
326+
327+
def parse_args(parser: argparse.ArgumentParser):
328+
"""Parse command line arguments."""
325329
return parser.parse_args()
326330

327331

@@ -331,7 +335,8 @@ def main():
331335
project_root = os.path.dirname(os.path.realpath(__file__))
332336
outdir = os.path.join(project_root, "plotly")
333337

334-
args = parse_args()
338+
parser = make_parser()
339+
args = parse_args(parser)
335340

336341
if args.cmd == "codegen":
337342
perform_codegen(outdir, noformat=args.noformat)
@@ -349,6 +354,10 @@ def main():
349354
version = plotly_js_version()
350355
print(version)
351356
update_plotlyjs(version, outdir)
357+
358+
elif args.cmd is None:
359+
parser.print_help()
360+
sys.exit(1)
352361

353362
else:
354363
print(f"unknown command {args.cmd}", file=sys.stderr)

0 commit comments

Comments
 (0)