Passed
Pull Request — master (#2)
by William
01:10
created

module_renamer.cli.analyze()   B

Complexity

Conditions 1

Size

Total Lines 32
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
cc 1
nop 4
1
# -*- coding: utf-8 -*-
2
"""Console script for module_renamer."""
3
from __future__ import absolute_import
4
5
import sys
6
7
import click
0 ignored issues
show
introduced by
Unable to import 'click'
Loading history...
8
9
from .commands.analyze_modifications import analyze_modifications
10
11
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
12
13
14
@click.group(context_settings=CONTEXT_SETTINGS)
15
def main():
16
    """
17
    Console script for module_renamer.
18
    """
19
    pass
20
21
22
@main.command()
23
@click.argument('project_path', type=click.Path(exists=True))
24
@click.option('--compare-with', default='master',
25
              help='Branch to be compared with [Default: master]')
26
@click.option('--branch', default=False,
27
              help='Branch that has the modifications [Default: current active branch]')
28
@click.option('--output-file', default='list_output.py',
29
              help='Change the name of the output file [Default: list_output.py]')
30
def analyze(project_path, compare_with, branch, output_file):
31
    """
32
    Generate the difference between the imports on two different branches.
33
34
    Command to analyze all modifications made between two different branches. The output will be a
35
    list written directly to a file (which will later be used by the script to rename the imports)
36
37
    Ex.:
38
    The following command generate a "list_output.py" with the difference between the
39
    current branch (that contains the modification) against the master.
40
41
    > renamer analyze project_path
42
43
    It's possible to use the flag --branch to point to branch different than the current one.
44
    It's possible to set --output-file to change the default output file name.
45
46
    > renamer analyze project_path --branch=my-branch --output-file=my_file.py
47
48
    And finally, it's possible to change the branch with which the modifications will be compared.
49
50
    > renamer analyze project_path --branch=my-branch --compare-with=my-other-branch
51
52
    """
53
    analyze_modifications(project_path, compare_with, branch, output_file)
54
55
56
if __name__ == "__main__":
57
    sys.exit(main())  # pragma: no cover
58