aboutsummaryrefslogtreecommitdiff
path: root/files/.task
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2020-09-23 22:06:27 +0500
committerAnton Bobov <abobov@gmail.com>2020-09-25 16:57:17 +0500
commit9784c2e0469e7c8619cacbfb14249288763bba87 (patch)
tree792ca7dac03072529ea89908adc228b7d022346e /files/.task
parent7494421ec6281de1ee7d327601223537b325a7a1 (diff)
Updates.
Diffstat (limited to 'files/.task')
-rwxr-xr-xfiles/.task/hooks/on-add-spell-check.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/files/.task/hooks/on-add-spell-check.py b/files/.task/hooks/on-add-spell-check.py
index 16758f0..6ddb6de 100755
--- a/files/.task/hooks/on-add-spell-check.py
+++ b/files/.task/hooks/on-add-spell-check.py
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
-from glob import glob
-from os.path import isfile, splitext
import os
import re
import sys
+from glob import glob
+from os.path import isfile, splitext
try:
from hunspell import HunSpell
@@ -12,7 +12,6 @@ except ImportError as e:
print(e)
sys.exit(0)
-
DICT_PATH = '/usr/share/hunspell/'
LANGS = ['en_US', 'ru_RU']
ENV_SKIP = 'TW_IGNORE_SPELL'
@@ -41,10 +40,20 @@ def spellcheck(text):
return errors
+
+def should_run_spellcheck(task):
+ if len(sys.argv) > 1:
+ opts = dict(arg.split(':', 1) for arg in sys.argv[1:])
+ command = opts['command']
+ return command in ['add', 'append', 'log', 'modify', 'prepend']
+ return False
+
+
task = Task.from_input()
-errors = spellcheck(task['description'])
-if len(errors) > 0:
- print('Spell errors:', ', '.join(errors))
- if not ENV_SKIP in os.environ:
- sys.exit(1)
+if should_run_spellcheck(task):
+ errors = spellcheck(task['description'])
+ if len(errors) > 0:
+ print('Spell errors:', ', '.join(errors))
+ if not ENV_SKIP in os.environ:
+ sys.exit(1)
print(task.export_data())