nameless.cli   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 13
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A run() 0 4 1
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