aboutsummaryrefslogtreecommitdiff
path: root/src/cli.py
blob: ec1a324e06886e24a9bba64fe2d971877332397f (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
class CommandLineInterface:
    def __init__(self):
        pass

    def parse_args(self):
        parse = argparse.ArgumentParser(prog="dslr_cli",
                                        description="CLI for the dslr project")
        subparser = parser.add_subparsers(dest="subparser_name")
        parser_describe = subparsers.add_parser("describe",
                                                help="give useful information about a dataset")
        parser_describe.add_argument("path", help="path to the dataset")
        parser_describe.set_defaults(func=self._describe)

        self.args = parser.parse_args(sys.argv[1:])

    def exec_args(self):
        if self.args.subparser_name is None:
            print("{} --help for more information".format(sys.argv[0]))
            return
        self.args.func()

    def _describe(self):
        describe.describe(self.args.path)


if __name__ == "__main__":
    cli = CommandLineInterface()
    cli.parse_args()
    cli.exec_args()