feat(py): command to export a note
This commit is contained in:
parent
8899cd33bb
commit
6711a57e25
12
cli/app.py
12
cli/app.py
|
@ -6,13 +6,13 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def listnotes(filter = "", grep = False):
|
def listnotes(filter = "", checkcontent = False):
|
||||||
matching = []
|
matching = []
|
||||||
for i in reversed(range(len(data))):
|
for i in reversed(range(len(data))):
|
||||||
if filter.lower() in data[i]["title"].lower():
|
if filter.lower() in data[i]["title"].lower():
|
||||||
print("[" + str(i) + "]", data[i]["title"])
|
print("[" + str(i) + "]", data[i]["title"])
|
||||||
matching.append(data[i])
|
matching.append(data[i])
|
||||||
elif grep and filter.lower() in data[i]["content"].lower():
|
elif checkcontent and filter.lower() in data[i]["content"].lower():
|
||||||
print("[" + str(i) + "]", data[i]["title"])
|
print("[" + str(i) + "]", data[i]["title"])
|
||||||
for line in data[i]["content"].split("\n"):
|
for line in data[i]["content"].split("\n"):
|
||||||
if filter.lower() in line.lower():
|
if filter.lower() in line.lower():
|
||||||
|
@ -80,8 +80,8 @@ if os.path.isfile("data/backupdata.acs"):
|
||||||
os.remove("data/backupdata.acs")
|
os.remove("data/backupdata.acs")
|
||||||
|
|
||||||
data = loaddata()
|
data = loaddata()
|
||||||
|
|
||||||
command = ""
|
command = ""
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
command = sys.argv[1]
|
command = sys.argv[1]
|
||||||
if command.startswith("notes://"):
|
if command.startswith("notes://"):
|
||||||
|
@ -102,6 +102,9 @@ while not (command == "quit" or command == "exit" or command == "q"):
|
||||||
elif command[0:4] == "sms ":
|
elif command[0:4] == "sms ":
|
||||||
action = "sms"
|
action = "sms"
|
||||||
command = command[4:]
|
command = command[4:]
|
||||||
|
elif command[0:7] == "export ":
|
||||||
|
action = "export"
|
||||||
|
command = command[7:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
index = int(command)
|
index = int(command)
|
||||||
|
@ -122,6 +125,9 @@ while not (command == "quit" or command == "exit" or command == "q"):
|
||||||
elif action == "sms":
|
elif action == "sms":
|
||||||
if note and ask("send '" + note["title"] + "' by sms? "):
|
if note and ask("send '" + note["title"] + "' by sms? "):
|
||||||
subprocess.call(["curl", "-s", "-X", "POST", "-F", "action=sms", "-F", "password=" + settings["password"], "-F", "data=" + urllib.parse.quote_plus(note["content"]), settings["url"] + "/handler.php"])
|
subprocess.call(["curl", "-s", "-X", "POST", "-F", "action=sms", "-F", "password=" + settings["password"], "-F", "data=" + urllib.parse.quote_plus(note["content"]), settings["url"] + "/handler.php"])
|
||||||
|
elif action == "export":
|
||||||
|
if note:
|
||||||
|
writetextfile("data/" + note["title"] + ".md", note["content"])
|
||||||
elif note and not action == "grep":
|
elif note and not action == "grep":
|
||||||
editnote(note)
|
editnote(note)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue