Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2015 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of toktokkie.
6toktokkie is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11toktokkie is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20import argparse
21from puffotter.init import argparse_add_verbosity
22from toktokkie.commands import toktokkie_commands
25def main(args: argparse.Namespace):
26 """
27 The main function of this script
28 :param args: The command line arguments
29 :return: None
30 """
31 for command_cls in toktokkie_commands:
32 if command_cls.name() == args.command:
33 command = command_cls(args)
34 command.execute()
37def define_parser() -> argparse.ArgumentParser:
38 """
39 :return: The command line parser for this script
40 """
41 parser = argparse.ArgumentParser()
42 argparse_add_verbosity(parser)
43 command_parser = parser.add_subparsers(dest="command")
44 command_parser.required = True
46 for command_cls in sorted(toktokkie_commands, key=lambda x: x.name()):
47 subparser = command_parser.add_parser(
48 command_cls.name(), help=command_cls.help()
49 )
50 argparse_add_verbosity(subparser)
51 command_cls.prepare_parser(subparser)
53 return parser