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] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entity-type ENTITY_TYPE] [--proxy PROXY] [--entity-type ENTITY_TYPE] [--proxy PROXY]
[--project PROJECT] [--alternate-project ALTERNATE_PROJECT] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE] [--language ALTERNATE_LANGUAGE] [--hostname HOSTNAME]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames] [--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats] [--include INCLUDE] [--extra-heartbeats] [--logfile LOGFILE]
[--logfile LOGFILE] [--apiurl API_URL] [--timeout TIMEOUT] [--apiurl API_URL] [--timeout TIMEOUT] [--config CONFIG]
[--config CONFIG] [--verbose] [--version] [--verbose] [--version]
wakatime: error: argument --timeout: invalid int value: 'abc' 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] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entity-type ENTITY_TYPE] [--proxy PROXY] [--entity-type ENTITY_TYPE] [--proxy PROXY]
[--project PROJECT] [--alternate-project ALTERNATE_PROJECT] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE] [--language ALTERNATE_LANGUAGE] [--hostname HOSTNAME]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames] [--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats] [--include INCLUDE] [--extra-heartbeats] [--logfile LOGFILE]
[--logfile LOGFILE] [--apiurl API_URL] [--timeout TIMEOUT] [--apiurl API_URL] [--timeout TIMEOUT] [--config CONFIG]
[--config CONFIG] [--verbose] [--version] [--verbose] [--version]
Common interface for the WakaTime api. Common interface for the WakaTime api.
@ -35,7 +35,7 @@ optional arguments:
--alternate-project ALTERNATE_PROJECT --alternate-project ALTERNATE_PROJECT
optional alternate project name; auto-discovered optional alternate project name; auto-discovered
project takes priority project takes priority
--alternate-language ALTERNATE_LANGUAGE --language ALTERNATE_LANGUAGE
optional alternate language name; if valid, takes optional alternate language name; if valid, takes
priority over auto-detected language priority over auto-detected language
--hostname HOSTNAME hostname of current machine. --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.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called() 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): def test_extra_heartbeats_argument(self):
response = Response() response = Response()
response.status_code = 201 response.status_code = 201

View file

@ -112,7 +112,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py' 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) retval = execute(args)
self.assertEquals(retval, 102) self.assertEquals(retval, 102)
@ -132,7 +132,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py' 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) retval = execute(args)
self.assertEquals(retval, 102) self.assertEquals(retval, 102)
@ -150,7 +150,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py' 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) retval = execute(args)
self.assertEquals(retval, 102) self.assertEquals(retval, 102)
@ -169,7 +169,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py' 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) retval = execute(args)
self.assertEquals(retval, 102) self.assertEquals(retval, 102)
@ -191,7 +191,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py' 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) retval = execute(args)
self.assertEquals(retval, 102) self.assertEquals(retval, 102)

View file

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