/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-07 20:57:16 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190307205716-n1yj0lz23k143u0l
mandos-ctl: Refactor; extract syntax check to separate function

* mandos-ctl (check_option_syntax): New.
  (main): Call check_option_syntax().

Show diffs side-by-side

added added

removed removed

Lines of Context:
644
644
    return commands
645
645
 
646
646
 
647
 
def main():
648
 
    parser = argparse.ArgumentParser()
649
 
 
650
 
    add_command_line_options(parser)
651
 
 
652
 
    options = parser.parse_args()
 
647
def check_option_syntax(parser, options):
653
648
 
654
649
    def has_actions(options):
655
650
        return any((options.enable,
683
678
    if options.is_enabled and len(options.client) > 1:
684
679
        parser.error("--is-enabled requires exactly one client")
685
680
 
 
681
 
 
682
def main():
 
683
    parser = argparse.ArgumentParser()
 
684
 
 
685
    add_command_line_options(parser)
 
686
 
 
687
    options = parser.parse_args()
 
688
 
 
689
    check_option_syntax(parser, options)
 
690
 
686
691
    clientnames = options.client
687
692
 
688
693
    try:
1155
1160
        """Assert that parsing ARGS should result in an instance of
1156
1161
COMMAND_CLS with (optionally) all supplied attributes (CMD_ATTRS)."""
1157
1162
        options = self.parser.parse_args(args)
 
1163
        check_option_syntax(self.parser, options)
1158
1164
        commands = commands_from_options(options)
1159
1165
        self.assertEqual(len(commands), 1)
1160
1166
        command = commands[0]