MCPcopy Index your code
hub / github.com/dbcli/mycli / handle_cd_command

Function handle_cd_command

mycli/packages/special/utils.py:15–27  ·  view source on GitHub ↗

Handles a `cd` shell command by calling python's os.chdir.

(command: list[str])

Source from the content-addressed store, hash-verified

13
14
15def handle_cd_command(command: list[str]) -> tuple[bool, str | None]:
16 """Handles a `cd` shell command by calling python's os.chdir."""
17 if not command[0].lower() == 'cd':
18 return False, 'Not a cd command.'
19 if len(command) != 2:
20 return False, 'Exactly one directory name must be provided.'
21 directory = command[1]
22 try:
23 os.chdir(directory)
24 click.echo(os.getcwd(), err=True)
25 return True, None
26 except OSError as e:
27 return False, e.strerror
28
29
30def format_uptime(uptime_in_seconds: str) -> str:

Calls 1

echoMethod · 0.45