Skip to content

Commit

Permalink
new cmd: peek
Browse files Browse the repository at this point in the history
  • Loading branch information
logandhillon committed Jul 12, 2024
1 parent 7c5653f commit d640cee
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bdsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, stdout: TextIO, stdin: TextIO, **is_ssh: bool):
"throw": self.cmd_throw,
"cwd": lambda _: self.print(self.cwd()),
"go": self.cmd_go,
"peek": self.cmd_peek,
}

self.definitions = {}
Expand Down Expand Up @@ -72,6 +73,13 @@ def cmd_go(self, args):
self.path = path
else:
raise FileNotFoundError(f"{args[1]}: no such file or folder")

def cmd_peek(self, args):
if os.path.isfile(path := os.path.join(self.path, args[1])):
with open(path, 'r') as f:
self.print(f.read())
else:
raise FileNotFoundError(f"{args[1]}: no such file")

def run_line(self, line: str):
if line == "":
Expand Down

0 comments on commit d640cee

Please sign in to comment.