|
@ -71,9 +71,10 @@ def set_command(cursor: Cursor, cwd: str, command: str): |
|
|
|
|
|
|
|
|
def get_command(cursor: Cursor, cwd: str) -> str: |
|
|
def get_command(cursor: Cursor, cwd: str) -> str: |
|
|
"""Get the command for the current directory""" |
|
|
"""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,) |
|
|
"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): |
|
|
def dump_db(cursor: Cursor): |
|
@ -90,6 +91,7 @@ def main(): |
|
|
db = init_db() |
|
|
db = init_db() |
|
|
if arguments["set"]: |
|
|
if arguments["set"]: |
|
|
set_command(db.cursor(), os.getcwd(), arguments["<command>"]) |
|
|
set_command(db.cursor(), os.getcwd(), arguments["<command>"]) |
|
|
|
|
|
print("Saved command successfully") |
|
|
elif arguments["get"]: |
|
|
elif arguments["get"]: |
|
|
print(get_command(db.cursor(), os.getcwd())) |
|
|
print(get_command(db.cursor(), os.getcwd())) |
|
|
elif arguments["dump"]: |
|
|
elif arguments["dump"]: |
|
|