aboutsummaryrefslogtreecommitdiff
path: root/cli.py
blob: 8880550529cd03a8ee885c354ded6d23d8ebd2c1 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3

import argparse
import scanfiles
import linkdeps

parser = argparse.ArgumentParser(
        description="Scan a dir for files and output includes",
        epilog="Example: cli.py ~/my/project -t .c .h")

parser.add_argument("dir")
parser.add_argument("-t", "--types", metavar="filetype", nargs="+",
                    default=[".c",".cpp",".h"],
                    help="what filetypes it should scan")
parser.add_argument("-g", "--ginc", action="store_true",
                    help="print global includes")
parser.add_argument("-l", "--linc", action="store_true",
                    help="print local includes")
parser.add_argument("-d", "--ifdef", action="store_true",
                    help="print includes the depends on ifdefs")

args = parser.parse_args()

#print(args.dir)
#print(args.types)

#inclst is a list of includes. First in it is global then local.

inclst = scanfiles.scanproject(args.dir,"makefile")
packages = []
for dep in inclst[0]:
    packages += linkdeps.deptopackage(dep)

if args.ginc == args.linc == args.ifdef == False:
    print(inclst)
    print(packages)

if args.ginc:
    print(inclst[0])
if args.linc:
    print(inclst[1])

if args.ifdef:
    for name in inclst[2]:
        print(name)
        print(inclst[2][name][0])
        print(inclst[2][name][1])