aboutsummaryrefslogtreecommitdiff
path: root/tabsvsspaces/_main.py
blob: b9f6389a222ce2eb930c7338845f8cebfc295b30 (plain)
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
import argparse
from pathlib import Path

from tabsvsspaces.pathtype import PathType
from tabsvsspaces.find_stats import find_stats
from tabsvsspaces.print_stats import print_stats
from tabsvsspaces.stats import Statistics


def main(args=None):
    parser = argparse.ArgumentParser(
        prog='tabsvsspaces',
        description='Shows statistics about the usage of tabs and spaces in a given folder'
    )
    parser.add_argument('folder',
                        type=PathType(type='dir', exists=True))
    parser.add_argument('--by-extension', '-e',
                        dest='extension',
                        action='store_true',
                        help='show distribution by file extension'
                        )
    parser.add_argument('--verbose', '-v',
                        dest='verbose',
                        action='store_true',
                        help='show debug information')
    ns = parser.parse_args(args)
    folder: str = ns.folder
    extension: bool = ns.extension
    verbose: bool = ns.verbose
    stats: Statistics = find_stats(Path(folder), verbose=verbose)
    print_stats(stats, extension)