rename --alternate-language to --language

This commit is contained in:
Alan Hamlett 2017-02-20 15:17:45 -08:00
parent b147afcd0e
commit 35726f2e91
5 changed files with 39 additions and 17 deletions

View file

@ -2,9 +2,9 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entity-type ENTITY_TYPE] [--proxy PROXY]
[--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats]
[--logfile LOGFILE] [--apiurl API_URL] [--timeout TIMEOUT]
[--config CONFIG] [--verbose] [--version]
[--language ALTERNATE_LANGUAGE] [--hostname HOSTNAME]
[--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
[--include INCLUDE] [--extra-heartbeats] [--logfile LOGFILE]
[--apiurl API_URL] [--timeout TIMEOUT] [--config CONFIG]
[--verbose] [--version]
wakatime: error: argument --timeout: invalid int value: 'abc'

View file

@ -2,11 +2,11 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entity-type ENTITY_TYPE] [--proxy PROXY]
[--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats]
[--logfile LOGFILE] [--apiurl API_URL] [--timeout TIMEOUT]
[--config CONFIG] [--verbose] [--version]
[--language ALTERNATE_LANGUAGE] [--hostname HOSTNAME]
[--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
[--include INCLUDE] [--extra-heartbeats] [--logfile LOGFILE]
[--apiurl API_URL] [--timeout TIMEOUT] [--config CONFIG]
[--verbose] [--version]
Common interface for the WakaTime api.
@ -35,7 +35,7 @@ optional arguments:
--alternate-project ALTERNATE_PROJECT
optional alternate project name; auto-discovered
project takes priority
--alternate-language ALTERNATE_LANGUAGE
--language ALTERNATE_LANGUAGE
optional alternate language name; if valid, takes
priority over auto-detected language
--hostname HOSTNAME hostname of current machine.

View file

@ -389,6 +389,22 @@ class MainTestCase(utils.TestCase):
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
def test_old_alternate_language_argument_still_supported(self):
response = Response()
response.status_code = 500
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', 'JAVA']
retval = execute(args)
self.assertEquals(retval, 102)
language = u('Java')
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
def test_extra_heartbeats_argument(self):
response = Response()
response.status_code = 201

View file

@ -112,7 +112,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', 'JAVA']
args = ['--file', entity, '--config', config, '--time', now, '--language', 'JAVA']
retval = execute(args)
self.assertEquals(retval, 102)
@ -132,7 +132,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', language.upper()]
args = ['--file', entity, '--config', config, '--time', now, '--language', language.upper()]
retval = execute(args)
self.assertEquals(retval, 102)
@ -150,7 +150,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', 'java', '--plugin', 'NeoVim/703 vim-wakatime/4.0.9']
args = ['--file', entity, '--config', config, '--time', now, '--language', 'java', '--plugin', 'NeoVim/703 vim-wakatime/4.0.9']
retval = execute(args)
self.assertEquals(retval, 102)
@ -169,7 +169,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', 'foo', '--plugin', 'NeoVim/703 vim-wakatime/4.0.9']
args = ['--file', entity, '--config', config, '--time', now, '--language', 'foo', '--plugin', 'NeoVim/703 vim-wakatime/4.0.9']
retval = execute(args)
self.assertEquals(retval, 102)
@ -191,7 +191,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', 'foo', '--plugin', 'NeoVim/703 vim-wakatime/4.0.9']
args = ['--file', entity, '--config', config, '--time', now, '--language', 'foo', '--plugin', 'NeoVim/703 vim-wakatime/4.0.9']
retval = execute(args)
self.assertEquals(retval, 102)

View file

@ -81,7 +81,9 @@ def parseArguments():
parser.add_argument('--alternate-project', dest='alternate_project',
help='optional alternate project name; auto-discovered project '+
'takes priority')
parser.add_argument('--alternate-language', dest='alternate_language',
parser.add_argument('--alternate-language', dest='alternate_language_old',
help=argparse.SUPPRESS)
parser.add_argument('--language', dest='alternate_language',
help='optional alternate language name; if valid, takes priority '+
'over auto-detected language')
parser.add_argument('--hostname', dest='hostname', help='hostname of '+
@ -159,6 +161,10 @@ def parseArguments():
args.entity = args.file
else:
parser.error('argument --entity is required')
if not args.alternate_language and args.alternate_language_old:
args.alternate_language = args.alternate_language_old
if not args.exclude:
args.exclude = []
if configs.has_option('settings', 'ignore'):