We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 07bc984 commit 468e0c6Copy full SHA for 468e0c6
1 file changed
implement-shell-tools/ls/ls.py
@@ -0,0 +1,20 @@
1
+import argparse
2
+import os
3
+parser=argparse.ArgumentParser(description="ls command")
4
+parser.add_argument("-1",dest="one_per_line",action="store_true",help="List one file per line")
5
+parser.add_argument("-a",dest="all", action="store_true",help="Include hidden files")
6
+parser.add_argument("path", nargs="?", default=".", help="Directory to list")
7
+
8
+args=parser.parse_args()
9
+files=os.listdir(args.path)
10
+if not args.all:
11
+ new_files=[]
12
+ for f in files:
13
+ if not f.startswith("."):
14
+ new_files.append(f)
15
+ files=new_files
16
+if args.one_per_line:
17
18
+ print(f)
19
+else:
20
+ print(" ".join(files))
0 commit comments