Skip to content

Commit 5fe87a0

Browse files
committed
Add -a flag to show hidden files
1 parent e862624 commit 5fe87a0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33

44
args = sys.argv[1:]
55

6-
# default folder = current folder
6+
show_all = False
77
path = "."
88

9-
# if user gives a folder
10-
if len(args) > 1:
11-
path = args[1]
9+
for arg in args:
10+
11+
if arg == "-a":
12+
show_all = True
13+
14+
elif arg != "-1":
15+
path = arg
1216

1317
files = os.listdir(path)
1418

1519
for file in files:
20+
21+
if not show_all and file.startswith("."):
22+
continue
23+
1624
print(file)

0 commit comments

Comments
 (0)