diff --git a/.pylintrc b/.pylintrc index 4d370eb3c..bf318704a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -38,7 +38,7 @@ load-plugins=linter_plugin # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=fixme,locally-disabled,abstract-class-not-used +disable=fixme,locally-disabled,abstract-class-not-used,bad-continuation,too-few-public-methods,no-self-use # abstract-class-not-used cannot be disabled locally (at least in pylint 1.4.1) @@ -101,7 +101,7 @@ function-rgx=[a-z_][a-z0-9_]{2,40}$ function-name-hint=[a-z_][a-z0-9_]{2,40}$ # Regular expression matching correct variable names -variable-rgx=[a-z_][a-z0-9_]{2,30}$ +variable-rgx=[a-z_][a-z0-9_]{1,30}$ # Naming hint for variable names variable-name-hint=[a-z_][a-z0-9_]{2,30}$ @@ -228,7 +228,8 @@ max-module-lines=1250 indent-string=' ' # Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 +# This does something silly/broken... +#indent-after-paren=4 [TYPECHECK] diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 0e7211a81..5e48b54be 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -361,7 +361,6 @@ class HelpfulArgumentParser(object): """ def __init__(self, args, plugins): - self.args = args plugin_names = [name for name, _p in plugins.iteritems()] self.help_topics = HELP_TOPICS + plugin_names + [None] self.parser = configargparse.ArgParser( @@ -374,6 +373,7 @@ class HelpfulArgumentParser(object): self.parser._add_config_file_help = False # pylint: disable=protected-access self.silent_parser = SilentParser(self.parser) + self.args = self.preprocess_args(args) help1 = self.prescan_for_flag("-h", self.help_topics) help2 = self.prescan_for_flag("--help", self.help_topics) assert max(True, "a") == "a", "Gravity changed direction" @@ -386,6 +386,17 @@ class HelpfulArgumentParser(object): #print self.visible_topics self.groups = {} # elements are added by .add_group() + def preprocess_args(self, args): + """Work around some limitations in argparse. + + Currently, add the default verb "run" as a default. + """ + + for token in args: + if token in VERBS: + return args + return ["run"] + args + def prescan_for_flag(self, flag, possible_arguments): """Checks cli input for flags. @@ -550,7 +561,12 @@ def create_parser(plugins, args): _create_subparsers(helpful) - return helpful.parser + return helpful.parser, helpful.args + +# For now unfortunately this constant just needs to match the code below; +# there isn't an elegant way to autogenerate it in time. +VERBS = ["run", "auth", "install", "revoke", "rollback", "config_changes",\ + "plugins"] def _create_subparsers(helpful): @@ -738,7 +754,8 @@ def main(cli_args=sys.argv[1:]): # note: arg parser internally handles --help (and exits afterwards) plugins = plugins_disco.PluginsRegistry.find_all() - args = create_parser(plugins, cli_args).parse_args(cli_args) + parser, tweaked_cli_args = create_parser(plugins, cli_args) + args = parser.parse_args(tweaked_cli_args) config = configuration.NamespaceConfig(args) # Setup logging ASAP, otherwise "No handlers could be found for