38
38
)
39
39
40
40
41
- __version__ = "2.0.0 "
41
+ __version__ = "2.0.1 "
42
42
43
43
44
44
def input_with_handling (_input : Callable ) -> Callable :
@@ -168,6 +168,13 @@ def _confirm(prompt: str) -> bool:
168
168
def _complete_from_key (d : Dict , text : str ) -> List [str ]:
169
169
return [k for k , v in d .items () if k .startswith (text )]
170
170
171
+ @staticmethod
172
+ def _shlex_path (path : str ) -> List [str ]:
173
+ lexer = shlex .shlex (path , posix = True )
174
+ lexer .escape = ""
175
+ lexer .whitespace_split = True
176
+ return list (lexer )
177
+
171
178
KNOWN_ROLES = tuple (MessageRole )
172
179
173
180
@classmethod
@@ -889,7 +896,7 @@ def do_save(self, arg):
889
896
Save all named threads to the specified json file. With no argument,
890
897
save to the most recently loaded/saved JSON file in this session.
891
898
"""
892
- args = shlex . split (arg )
899
+ args = self . __class__ . _shlex_path (arg )
893
900
if len (args ) > 1 :
894
901
print ("Usage: save [path]" )
895
902
return
@@ -929,7 +936,7 @@ def do_load(self, arg, _print_on_success=True):
929
936
print ("Usage: load <path>\n " )
930
937
return
931
938
try :
932
- args = shlex . split (arg )
939
+ args = self . __class__ . _shlex_path (arg )
933
940
except ValueError as e :
934
941
print (e )
935
942
return
@@ -983,7 +990,7 @@ def do_read(self, arg):
983
990
example: "read /path/to/prompt.txt system"
984
991
"""
985
992
try :
986
- args = shlex . split (arg )
993
+ args = self . __class__ . _shlex_path (arg )
987
994
except ValueError as e :
988
995
print (e )
989
996
return
@@ -1010,7 +1017,7 @@ def complete_read(self, text, line, begidx, endidx):
1010
1017
def do_write (self , arg ):
1011
1018
"Write the contents of the last message to the specified file."
1012
1019
try :
1013
- args = shlex . split (arg )
1020
+ args = self . __class__ . _shlex_path (arg )
1014
1021
except ValueError as e :
1015
1022
print (e )
1016
1023
return
@@ -1041,7 +1048,7 @@ def do_transcribe(self, arg):
1041
1048
specified file.
1042
1049
"""
1043
1050
try :
1044
- args = shlex . split (arg )
1051
+ args = self . __class__ . _shlex_path (arg )
1045
1052
except ValueError as e :
1046
1053
print (e )
1047
1054
return
@@ -1083,7 +1090,7 @@ def do_image(self, arg):
1083
1090
img = Image (url = location )
1084
1091
else :
1085
1092
try :
1086
- img = Image .from_path (shlex . split (location )[0 ])
1093
+ img = Image .from_path (self . __class__ . _shlex_path (location )[0 ])
1087
1094
except (OSError , FileNotFoundError , ValueError ) as e :
1088
1095
print (e )
1089
1096
return
0 commit comments