Browse Source

Fix crash when no command set

master
Schneider 4 years ago
parent
commit
6b41d602cf
Signed by: schneider GPG Key ID: 3F50B02A50039F3B
  1. 6
      dirbuild.py

6
dirbuild.py

@ -71,9 +71,10 @@ def set_command(cursor: Cursor, cwd: str, command: str):
def get_command(cursor: Cursor, cwd: str) -> str:
"""Get the command for the current directory"""
return cursor.execute(
cmd = cursor.execute(
"SELECT cmd FROM commands WHERE dir = ? ORDER BY id DESC LIMIT 1", (cwd,)
).fetchone()[0]
).fetchone()
return cmd[0] if cmd is not None else ""
def dump_db(cursor: Cursor):
@ -90,6 +91,7 @@ def main():
db = init_db()
if arguments["set"]:
set_command(db.cursor(), os.getcwd(), arguments["<command>"])
print("Saved command successfully")
elif arguments["get"]:
print(get_command(db.cursor(), os.getcwd()))
elif arguments["dump"]:

Loading…
Cancel
Save