python tool:
- curl not silent - questions are now "yes" by default - replace grep by / - ask before opening note if only one found
This commit is contained in:
parent
f4029760a1
commit
afd8c2de24
16
cli/app.py
16
cli/app.py
|
@ -57,21 +57,21 @@ def savedata():
|
||||||
newdata = readtextfile("data/data.acs")
|
newdata = readtextfile("data/data.acs")
|
||||||
postdata = "action=push&password=" + settings["password"] + "&data=" + urllib.parse.quote_plus(newdata)
|
postdata = "action=push&password=" + settings["password"] + "&data=" + urllib.parse.quote_plus(newdata)
|
||||||
writetextfile("data/postdata", postdata)
|
writetextfile("data/postdata", postdata)
|
||||||
subprocess.call(["curl", "-s", "-X", "POST", "-d", "@data/postdata", settings["url"] + "/handler.php"])
|
subprocess.call(["curl", "-X", "POST", "-d", "@data/postdata", settings["url"] + "/handler.php"])
|
||||||
else:
|
else:
|
||||||
writetextfile("data/local.json", json.dumps(data))
|
writetextfile("data/local.json", json.dumps(data))
|
||||||
|
|
||||||
def loaddata():
|
def loaddata():
|
||||||
if settings["mode"] == "remote":
|
if settings["mode"] == "remote":
|
||||||
subprocess.call(["curl", "-s", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings["password"], "-o", "data/backupdata.acs", settings["url"] + "/handler.php"])
|
subprocess.call(["curl", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings["password"], "-o", "data/backupdata.acs", settings["url"] + "/handler.php"])
|
||||||
subprocess.call([settings["commands"]["gpg"], "-q", "--yes", "--output", "data/backupdata.json", "--decrypt", "data/backupdata.acs"])
|
subprocess.call([settings["commands"]["gpg"], "-q", "--yes", "--output", "data/backupdata.json", "--decrypt", "data/backupdata.acs"])
|
||||||
return json.loads(readtextfile("data/backupdata.json"))
|
return json.loads(readtextfile("data/backupdata.json"))
|
||||||
else:
|
else:
|
||||||
return json.loads(readtextfile("data/local.json"))
|
return json.loads(readtextfile("data/local.json"))
|
||||||
|
|
||||||
def ask(question):
|
def ask(question):
|
||||||
answer = input(question)
|
answer = input(question + " [Y/n] ")
|
||||||
return answer == "y" or answer == "yes"
|
return answer == "y" or answer == "yes" or answer == ""
|
||||||
|
|
||||||
abspath = os.path.abspath(__file__)
|
abspath = os.path.abspath(__file__)
|
||||||
dname = os.path.dirname(abspath)
|
dname = os.path.dirname(abspath)
|
||||||
|
@ -98,9 +98,9 @@ while not (command == "quit" or command == "exit" or command == "q"):
|
||||||
elif command[0:3] == "mv ":
|
elif command[0:3] == "mv ":
|
||||||
action = "rename"
|
action = "rename"
|
||||||
command = command[3:]
|
command = command[3:]
|
||||||
elif command[0:5] == "grep ":
|
elif command[0:1] == "/":
|
||||||
action = "grep"
|
action = "grep"
|
||||||
command = command[5:]
|
command = command[1:]
|
||||||
elif command[0:4] == "sms ":
|
elif command[0:4] == "sms ":
|
||||||
action = "sms"
|
action = "sms"
|
||||||
command = command[4:]
|
command = command[4:]
|
||||||
|
@ -143,6 +143,8 @@ while not (command == "quit" or command == "exit" or command == "q"):
|
||||||
data.insert(0, note)
|
data.insert(0, note)
|
||||||
editnote(note)
|
editnote(note)
|
||||||
elif len(matching) == 1:
|
elif len(matching) == 1:
|
||||||
editnote(matching.pop())
|
note = matching.pop()
|
||||||
|
if ask("open '" + note["title"] + "'?"):
|
||||||
|
editnote(note)
|
||||||
|
|
||||||
command = input("> ")
|
command = input("> ")
|
||||||
|
|
Loading…
Reference in New Issue