Total Complexity | 1 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | Module that contains the command line app. |
||
3 | |||
4 | Why does this file exist, and why not put this in __main__? |
||
5 | |||
6 | You might be tempted to import things from __main__ later, but that will cause |
||
7 | problems: the code will get executed twice: |
||
8 | |||
9 | - When you run `python -mnameless` python will execute |
||
10 | ``__main__.py`` as a script. That means there will not be any |
||
11 | ``nameless.__main__`` in ``sys.modules``. |
||
12 | - When you import __main__ it will get executed again (as a module) because |
||
13 | there"s no ``nameless.__main__`` in ``sys.modules``. |
||
14 | |||
15 | Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration |
||
16 | """ |
||
17 | |||
18 | import argparse |
||
19 | |||
20 | from .core import compute |
||
21 | |||
22 | parser = argparse.ArgumentParser(description="Command description.") |
||
23 | parser.add_argument( |
||
24 | "names", |
||
25 | metavar="NAME", |
||
26 | nargs=argparse.ZERO_OR_MORE, |
||
27 | help="A name of something.", |
||
28 | ) |
||
29 | |||
30 | |||
31 | def run(args=None): |
||
32 | args = parser.parse_args(args=args) |
||
33 | print(compute(args.names)) |
||
34 | parser.exit(0) |
||
35 |