From c88eb083d8cc2e01fcdd906b7b1192047a60e1ab Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Thu, 25 Aug 2016 09:52:50 -0400 Subject: [PATCH] Bug 1258341 - [mozlint] Add ability to forward miscellaneous command line arguments to the underlying linter, r=smacleod This is mostly to maintain backwards compatibility with the |mach eslint| command. But it's also going to be used in automation. The 'mozlint-eslint' task will need to pass in --quiet to eslint. Maybe in the future we should remove this ability and only allow well-defined arguments in mozlint. But for now it's convenient and allows us to land the eslint->mozlint patch series quicker. MozReview-Commit-ID: KYhC6SEySC3 --HG-- extra : rebase_source : ad7f0cdeb57ed8a99becb90d761d73ef45ce853a --- python/mozlint/mozlint/cli.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/mozlint/mozlint/cli.py b/python/mozlint/mozlint/cli.py index 61cb9851611e..e1e9e932687f 100644 --- a/python/mozlint/mozlint/cli.py +++ b/python/mozlint/mozlint/cli.py @@ -6,7 +6,7 @@ from __future__ import print_function, unicode_literals import os import sys -from argparse import ArgumentParser +from argparse import ArgumentParser, REMAINDER SEARCH_PATHS = [] @@ -52,6 +52,10 @@ class MozlintParser(ArgumentParser): 'help': "Lint files touched by changes in the working directory " "(i.e haven't been committed yet). Works with mercurial or git.", }], + [['extra_args'], + {'nargs': REMAINDER, + 'help': "Extra arguments that will be forwarded to the underlying linter.", + }], ] def __init__(self, **kwargs): @@ -60,6 +64,13 @@ class MozlintParser(ArgumentParser): for cli, args in self.arguments: self.add_argument(*cli, **args) + def parse_known_args(self, *args, **kwargs): + # This is here so the eslint mach command doesn't lose 'extra_args' + # when using mach's dispatch functionality. + args, extra = ArgumentParser.parse_known_args(self, *args, **kwargs) + args.extra_args = extra + return args, extra + def find_linters(linters=None): lints = []