allow passing plugin arg wrapped in quotes once too many times
This commit is contained in:
parent
dbeca8bed0
commit
e3b0eac636
1 changed files with 9 additions and 1 deletions
|
@ -34,6 +34,14 @@ class FileAction(argparse.Action):
|
||||||
setattr(namespace, self.dest, values)
|
setattr(namespace, self.dest, values)
|
||||||
|
|
||||||
|
|
||||||
|
class StoreWithoutQuotes(argparse.Action):
|
||||||
|
|
||||||
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
|
if values.startswith('"'):
|
||||||
|
values = re.sub(r'\\"', '"', values.strip('"'))
|
||||||
|
setattr(namespace, self.dest, values)
|
||||||
|
|
||||||
|
|
||||||
def parseArguments():
|
def parseArguments():
|
||||||
"""Parse command line arguments and configs from ~/.wakatime.cfg.
|
"""Parse command line arguments and configs from ~/.wakatime.cfg.
|
||||||
Command line arguments take precedence over config file settings.
|
Command line arguments take precedence over config file settings.
|
||||||
|
@ -56,7 +64,7 @@ def parseArguments():
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='when set, tells api this heartbeat was triggered from '+
|
help='when set, tells api this heartbeat was triggered from '+
|
||||||
'writing to a file')
|
'writing to a file')
|
||||||
parser.add_argument('--plugin', dest='plugin',
|
parser.add_argument('--plugin', dest='plugin', action=StoreWithoutQuotes,
|
||||||
help='optional text editor plugin name and version '+
|
help='optional text editor plugin name and version '+
|
||||||
'for User-Agent header')
|
'for User-Agent header')
|
||||||
parser.add_argument('--time', dest='timestamp', metavar='time',
|
parser.add_argument('--time', dest='timestamp', metavar='time',
|
||||||
|
|
Loading…
Reference in a new issue