From 6cce5380ef1585f72dc4083297932489f793ca0b Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Wed, 16 Sep 2020 12:43:40 +0200 Subject: Make the main command boilerplate available to library users. --- scripts/lesana | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'scripts') 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() -- cgit v1.2.3