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 5f94d99..e33357a 100644 --- a/tests/samples/output/main_test_timeout_passed_via_command_line +++ b/tests/samples/output/main_test_timeout_passed_via_command_line @@ -1,7 +1,7 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS] - [--entitytype ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] - [--alternate-project ALTERNATE_PROJECT] + [--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] diff --git a/tests/samples/output/test_help_contents b/tests/samples/output/test_help_contents index c3f20ed..256bc4f 100644 --- a/tests/samples/output/test_help_contents +++ b/tests/samples/output/test_help_contents @@ -1,7 +1,7 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS] - [--entitytype ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] - [--alternate-project ALTERNATE_PROJECT] + [--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] @@ -25,9 +25,9 @@ optional arguments: --lineno LINENO optional line number; current line being edited --cursorpos CURSORPOS optional cursor position in the current file - --entitytype ENTITY_TYPE + --entity-type ENTITY_TYPE entity type for this heartbeat. can be one of "file", - "url", "domain", or "app"; defaults to file. + "domain", or "app"; defaults to file. --proxy PROXY optional https proxy url; for example: https://user:pass@localhost:8080 --project PROJECT optional project name diff --git a/tests/samples/output/test_missing_config_file b/tests/samples/output/test_missing_config_file index 609e257..7211d77 100644 --- a/tests/samples/output/test_missing_config_file +++ b/tests/samples/output/test_missing_config_file @@ -1,7 +1,7 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS] - [--entitytype ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] - [--alternate-project ALTERNATE_PROJECT] + [--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] diff --git a/tests/test_main.py b/tests/test_main.py index 91452a5..9b3d62e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -419,7 +419,7 @@ class BaseTestCase(utils.TestCase): config = 'tests/samples/configs/good_config.cfg' now = u(int(time.time())) - args = ['--entity', entity, '--entitytype', 'domain', '--config', config, '--time', now] + args = ['--entity', entity, '--entity-type', 'domain', '--config', config, '--time', now] retval = execute(args) self.assertEquals(retval, API_ERROR) @@ -456,7 +456,7 @@ class BaseTestCase(utils.TestCase): config = 'tests/samples/configs/good_config.cfg' now = u(int(time.time())) - args = ['--entity', entity, '--entitytype', 'app', '--config', config, '--time', now] + args = ['--entity', entity, '--entity-type', 'app', '--config', config, '--time', now] retval = execute(args) self.assertEquals(retval, API_ERROR) diff --git a/wakatime/main.py b/wakatime/main.py index ef104dd..0fff484 100644 --- a/wakatime/main.py +++ b/wakatime/main.py @@ -123,9 +123,9 @@ def parseArguments(): help='optional line number; current line being edited') parser.add_argument('--cursorpos', dest='cursorpos', help='optional cursor position in the current file') - parser.add_argument('--entitytype', dest='entity_type', + parser.add_argument('--entity-type', dest='entity_type', help='entity type for this heartbeat. can be one of "file", '+ - '"url", "domain", or "app"; defaults to file.') + '"domain", or "app"; defaults to file.') parser.add_argument('--proxy', dest='proxy', help='optional https proxy url; for example: '+ 'https://user:pass@localhost:8080') @@ -193,8 +193,6 @@ def parseArguments(): args.key = default_key else: parser.error('Missing api key') - if not args.entity_type: - args.entity_type = 'file' if not args.entity: if args.file: args.entity = args.file @@ -464,6 +462,9 @@ def process_heartbeat(args, configs, hostname, heartbeat): )) return SUCCESS + if heartbeat.get('entity_type') not in ['file', 'domain', 'app']: + heartbeat['entity_type'] = 'file' + if heartbeat['entity_type'] != 'file' or os.path.isfile(heartbeat['entity']): stats = get_file_stats(heartbeat['entity'],