summaryrefslogtreecommitdiff
path: root/lib/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/commands.py')
-rw-r--r--lib/commands.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/commands.py b/lib/commands.py
index c9525db..9616b8d 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -30,24 +30,25 @@ class Commands(object):
ListCommands.err('personal', e.value)
elif what == 'get':
try:
- if len(cmd) > 2 and cmd[1] != 'user?': raise PersonalError(Colors.grey + 'get ' + Colors.red + 'accetta 1 parametro')
-
- if cmd[1] == 'user':
- if self.user != '':
- print(r.hget('user:'+host, 'name').decode('utf-8'))
- else:
- print('nil')
- elif cmd[1] == 'host':
- print('localhost')
- elif cmd[1] == 'port':
- print('6379')
+ if len(cmd) > ListCommands.info['get'][1] and cmd[1] != 'user?': raise PersonalError(Colors.grey + 'get ' + Colors.red + 'accetta 2 parametri')
+
+ if cmd[1] == 'i':
+ if cmd[2] == 'user':
+ if self.user != '':
+ print(r.hget('user:'+host, 'name').decode('utf-8'))
+ else:
+ print('nil')
+ elif cmd[2] == 'host':
+ print('localhost')
+ elif cmd[2] == 'port':
+ print('6379')
+ elif cmd[2] not in ListCommands.commands['get'][1]:
+ ListCommands.err('keyword')
elif cmd[1] == 'user?':
if len(cmd) > 3: raise PersonalError(Colors.grey + 'get user?' + Colors.red + ' accetta 1 parametro')
- print(userexist(cmd[2]))
- elif cmd[1] not in ListCommands.commands:
- raise KeyError
+ print((lambda x: '0' if x == False else '1')(userexist(cmd[2])))
else:
- raise IndexError
+ raise KeyError
except IndexError:
ListCommands.err('wrong')
except KeyError: