Skip to content

Commit 3525df4

Browse files
committed
Simplify
1 parent 1eccbef commit 3525df4

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/gptcmd/cli.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -780,18 +780,13 @@ def do_read(self, arg):
780780
example: "read /path/to/prompt.txt system"
781781
"""
782782
args = arg.split()
783-
if len(args) < 2:
783+
if len(args) < 2 or not self.__class__._validate_role(args[-1]):
784784
print(
785-
"Usage: read <path> <{'|'.join(self.__class__.KNOWN_ROLES)}>"
785+
f"Usage: read <path> <{'|'.join(self.__class__.KNOWN_ROLES)}>"
786786
)
787787
return
788788
path = " ".join(args[:-1])
789789
role = args[-1]
790-
if not self.__class__._validate_role(role):
791-
print(
792-
f"Usage: read <path> <{'|'.join(self.__class__.KNOWN_ROLES)}>"
793-
)
794-
return
795790
try:
796791
with open(path, encoding="utf-8", errors="ignore") as fin:
797792
self._current_thread.append(

0 commit comments

Comments
 (0)