Quellcode durchsuchen

cmd_shell: create ~/.kamcli folder if not exists and history is enabled

Daniel-Constantin Mierla vor 5 Jahren
Ursprung
Commit
479f6675ea
1 geänderte Dateien mit 4 neuen und 0 gelöschten Zeilen
  1. 4 0
      kamcli/commands/cmd_shell.py

+ 4 - 0
kamcli/commands/cmd_shell.py

@@ -385,6 +385,10 @@ def cli(ctx, nohistory, nosyntax):
     prompt_kwargs = {}
     prompt_kwargs = {}
 
 
     if not nohistory:
     if not nohistory:
+        dirName = os.path.expanduser("~/.kamcli")
+        if not os.path.exists(dirName):
+            os.mkdir(dirName)
+            click.echo("directory '" + dirName + "' created")
         prompt_kwargs.update(
         prompt_kwargs.update(
             {"history": FileHistory(os.path.expanduser("~/.kamcli/history"))}
             {"history": FileHistory(os.path.expanduser("~/.kamcli/history"))}
         )
         )