Skip to content

Commit 47b933c

Browse files
authored
Create cd.py
1 parent 8c3613b commit 47b933c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

CoreShell/bin/cd.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
from bin.cwd import cwd
3+
4+
def cd(args=[]):
5+
if len(args)>0:
6+
try:
7+
os.chdir(args[0])
8+
output = f"cd: changed directory to '{cwd()}'"
9+
except:
10+
if os.path.isfile(args[0]):
11+
output = f"cd: '{args[0]}' is a file."
12+
else:
13+
output = f"cd: no such file or directory '{args([0])}'"
14+
else:
15+
output = "cd: no directory was provided."
16+
return output
17+
18+
def man(args=[]):
19+
output = "Changes the directory.\nUsage: cd [path]"
20+
return output

0 commit comments

Comments
 (0)