diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2020-09-16 12:43:40 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2020-09-16 12:43:40 +0200 |
commit | 6cce5380ef1585f72dc4083297932489f793ca0b (patch) | |
tree | ced8c374c1a3a0c162c8898c08f71657f15d5222 /scripts | |
parent | c7b332764115de5c41a518c64ce902adc3b9b924 (diff) |
Make the main command boilerplate available to library users.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/lesana | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/scripts/lesana b/scripts/lesana index c8e6b7f..8e34179 100755 --- a/scripts/lesana +++ b/scripts/lesana @@ -8,7 +8,7 @@ import argparse import lesana.command -class Lesana: +class Lesana(lesana.command.MainCommand): """ Manage collections """ @@ -25,21 +25,6 @@ class Lesana: ("rm", lesana.command.Remove()), ) - def _main(self, args): - self.parser.print_help() - - def main(self): - self.parser = argparse.ArgumentParser() - self.parser.set_defaults(func=self._main) - self.subparsers = self.parser.add_subparsers() - for name, sub in self.commands: - s_parser = self.subparsers.add_parser(name, help=sub.help) - for arg in sub.arguments: - s_parser.add_argument(*arg[0], **arg[1]) - s_parser.set_defaults(func=sub._main) - self.args = self.parser.parse_args() - self.args.func(self.args) - if __name__ == "__main__": Lesana().main() |