Skip to content

Commit 0087991

Browse files
committed
Improved error handling and install instructions
1 parent 2a034b2 commit 0087991

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ Git Time Metrics (GTM) is a tool to automatically track time spent reading and w
55

66
### Installation
77

8-
Use [Package Control](https://packagecontrol.io)
8+
Use [Package Control](https://packagecontrol.io), this package only supports Sublime Text 3.
99

10-
This package only supports Sublime Text 3.
11-
12-
Checkout the main [GTM repository](https://github.com/git-time-metric/gtm) for more information.
10+
In addition to the plug-in you will need to install GTM. Checkout the main [GTM repository](https://github.com/git-time-metric/gtm) for more information.

gtm-plugin.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,18 @@ class GTM(sublime_plugin.EventListener):
3737

3838
gtm_path = find_gtm_path()
3939

40+
no_gtm_err = ("GTM executable not found\n"
41+
"Install GTM and/or update your system path\n"
42+
"Make sure to restart Sublime after install\n"
43+
"See https://www.github.com/git-time-metric/gtm")
44+
45+
record_err = ("GTM error saving time\n"
46+
"Install GTM and/or update your system path\n"
47+
"Make sure to restart Sublime after install\n"
48+
"See https://www.github.com/git-time-metric/gtm")
49+
4050
if not gtm_path:
41-
print("Unable to find the 'gtm' executable")
42-
print("Please makes sure it is installed and accesible via your path")
51+
sublime.error_message(no_gtm_err)
4352

4453
def on_post_save_async(self, view):
4554
self.record(view, view.file_name())
@@ -55,7 +64,7 @@ def on_activated_async(self, view):
5564

5665
def record(self, view, path):
5766

58-
if path and (
67+
if GTM.gtm_path and path and (
5968
path != GTM.last_path or
6069
time.time() - GTM.last_update > GTM.update_interval ):
6170

@@ -66,5 +75,4 @@ def record(self, view, path):
6675
return_code = subprocess.call(cmd, shell=True)
6776

6877
if return_code != 0:
69-
print("Unable to run 'gtm' command")
70-
print("Please makes sure it is installed and accesible via your path")
78+
sublime.error_message(GTM.record_err)

0 commit comments

Comments
 (0)