From 254f0a821ad8401d5cc75c748bf635dbd335068a Mon Sep 17 00:00:00 2001 From: quadrismegistus Date: Mon, 14 Sep 2020 21:10:31 +0100 Subject: [PATCH] updates --- bin/komrade-app | 2 +- bin/komrade-cli | 2 +- bin/komrade-op | 2 +- komrade/backend/operators.py | 2 +- komrade/cli/cli.py | 21 +++++++++++++++++---- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bin/komrade-app b/bin/komrade-app index bfbb527..f727eb4 100755 --- a/bin/komrade-app +++ b/bin/komrade-app @@ -12,7 +12,7 @@ path=`realpath "$SCRIPTPATH/../komrade/app/main.py"` pathvenv=`realpath "$SCRIPTPATH/../venv/bin/activate"` source $pathvenv -python "$path" +python "$path" $* if command -v deactivate &> /dev/null diff --git a/bin/komrade-cli b/bin/komrade-cli index 77c1b5c..2e3da15 100755 --- a/bin/komrade-cli +++ b/bin/komrade-cli @@ -9,7 +9,7 @@ path=`realpath "$SCRIPTPATH/../komrade/cli/cli.py"` pathvenv=`realpath "$SCRIPTPATH/../venv/bin/activate"` source $pathvenv -python "$path" +python "$path" $* if command -v deactivate &> /dev/null diff --git a/bin/komrade-op b/bin/komrade-op index bc6f483..a21e6b1 100755 --- a/bin/komrade-op +++ b/bin/komrade-op @@ -10,7 +10,7 @@ pathvenv=`realpath "$SCRIPTPATH/../venv/bin/activate"` source $pathvenv -cmd="python $path 8080" +cmd="python $path 8080 $*" # do forever while true; do $cmd && break; done diff --git a/komrade/backend/operators.py b/komrade/backend/operators.py index fe240f3..961a8c7 100644 --- a/komrade/backend/operators.py +++ b/komrade/backend/operators.py @@ -75,7 +75,7 @@ class Operator(Keymaker): # add to phonebook if name: PHONEBOOK[name]=self - if self.pubkey: PHONEBOOK[self.pubkey.data_b64] + if self.pubkey: PHONEBOOK[self.pubkey.data_b64]=self @property diff --git a/komrade/cli/cli.py b/komrade/cli/cli.py index 5528555..ea382b1 100644 --- a/komrade/cli/cli.py +++ b/komrade/cli/cli.py @@ -7,6 +7,7 @@ HELPSTR = """ /login [name] --> log back in /register [name] --> new komrade /meet [name] --> exchange info + /msg [name] [msg] --> write to person or group /who [name] --> show contact info /help --> seek help """ @@ -17,7 +18,8 @@ class CLI(Logger): 'register':'join the komrades', 'login':'log back in', 'meet':'meet a komrade', - 'who':'show contacts or info' + 'who':'show contacts or info', + 'msg':'write people' } def __init__(self,name='',cmd='',persona=None): @@ -130,6 +132,16 @@ class CLI(Logger): # meet? self.komrade.meet(name) + def msg(self,dat): + name_or_pubkey,msg = dat.split(' ',1) + self.log(f'Composed msg to {name_or_pubkey}: {msg}') + + msg_obj = self.komrade.msg( + name_or_pubkey, + msg + ) + + self.log(f'Sent msg obj to {name_or_pubkey}: {msg_obj}') @@ -452,12 +464,13 @@ class CLI(Logger): -def run_cli(): +def run_cli(inp): cli = CLI() - cli.run() #'/register elon') #'/register',name='elon') + cli.run(inp) #'/register elon') #'/register',name='elon') if __name__=='__main__': - run_cli() + inp = ' '.join(sys.argv[1:]) + run_cli(inp) # asyncio.run(test_async())