From 35726f2e9138b144a81dbeff5c1f83e7fb1fa5ea Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Mon, 20 Feb 2017 15:17:45 -0800 Subject: [PATCH] rename --alternate-language to --language --- .../main_test_timeout_passed_via_command_line | 10 +++++----- tests/samples/output/test_help_contents | 12 ++++++------ tests/test_arguments.py | 16 ++++++++++++++++ tests/test_languages.py | 10 +++++----- wakatime/arguments.py | 8 +++++++- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/tests/samples/output/main_test_timeout_passed_via_command_line b/tests/samples/output/main_test_timeout_passed_via_command_line index e33357a..154906a 100644 --- a/tests/samples/output/main_test_timeout_passed_via_command_line +++ b/tests/samples/output/main_test_timeout_passed_via_command_line @@ -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' diff --git a/tests/samples/output/test_help_contents b/tests/samples/output/test_help_contents index 4728c76..c4fb4d4 100644 --- a/tests/samples/output/test_help_contents +++ b/tests/samples/output/test_help_contents @@ -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. diff --git a/tests/test_arguments.py b/tests/test_arguments.py index 04ab105..4a9bccb 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -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 diff --git a/tests/test_languages.py b/tests/test_languages.py index f9b50ee..7ea9bc0 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -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) diff --git a/wakatime/arguments.py b/wakatime/arguments.py index e0b1e5b..36bddad 100644 --- a/wakatime/arguments.py +++ b/wakatime/arguments.py @@ -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'):