Skip to content

Commit

Permalink
allow semicolon separated commands
Browse files Browse the repository at this point in the history
  • Loading branch information
lol-cubes committed Nov 25, 2019
1 parent d412399 commit 92a8bd8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 0 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
v1.1
Arrow keys in input
multiple commands at once separated by semicolon

v1.2
cloud storage

Expand Down
13 changes: 12 additions & 1 deletion cl_timer/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
ExitException, MutableString
)

import logging as l

logging = l.getLogger(__name__)

HOME = str(Path.home())

Expand Down Expand Up @@ -99,6 +102,12 @@ def interpret(command):
"""
Performs tasks according to what the command tells it
"""

if ';' in command:
for subcommand in command.split(';'):
interpret(subcommand.strip())
return

if command.count('"') % 2 != 0:
show_error_message('syntax error: odd number of quotes (")')

Expand Down Expand Up @@ -135,6 +144,8 @@ def interpret(command):
if command[-1] != '"':
words.append(command.split(' ')[-1])

logging.info(words)

if words[0] == 'alias':
if len(words) != 3:
show_error_message(f'`alias` takes exactly 2 arguments - {len(words) - 1} were given')
Expand Down Expand Up @@ -316,7 +327,7 @@ def interpret(command):
show_error_message(f'invalid time: {words[1]}')

elif words[0] in aliases.keys():
interpret(aliases[words[0]] + f' {"".join(words[1:])}')
interpret(aliases[words[0]] + f' {" ".join(words[1:])}')

else: # command was not recognized
show_error_message(f'{words[0]}: Invalid command')
Expand Down
4 changes: 4 additions & 0 deletions cl_timer/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
ExitException, MutableString
)

import logging

logging.basicConfig(filename='cl-timer.log', level=logging.INFO)

HOME = str(Path.home())

try:
Expand Down

0 comments on commit 92a8bd8

Please sign in to comment.