-
Notifications
You must be signed in to change notification settings - Fork 650
/
main.py
33 lines (26 loc) · 975 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
import argparse
from .commands import build, create, upgrade, version, page, toc, run
DESCRIPTION = (
"Jupyter Book: Generate an HTML book from your Jupyter Notebooks using"
" Jekyll. Type `jupyter-book <command> -h` for help.")
commands = {'create': create,
'build': build,
'page': page,
'upgrade': upgrade,
'run': run,
'toc': toc,
'version': version}
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument("command", help="The command you'd like to run. Allowed commands: {}".format(
list(commands.keys())))
def main():
args = parser.parse_args(sys.argv[1:2])
if args.command not in commands:
parser.print_help()
raise ValueError(
'Unrecognized command: {}\n See the help above for usage information'.format(args.command))
# Run the command
commands[args.command]()
if __name__ == "__main__":
main()