File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import sys
1+ import argparse
22import os
33
4- args = sys .argv [1 :]
4+ parser = argparse .ArgumentParser ()
5+ parser .add_argument ("-a" , "--all" , action = "store_true" )
6+ parser .add_argument ("-1" , dest = "one_per_line" , action = "store_true" )
7+ parser .add_argument ("path" , nargs = "?" , default = "." )
58
6- show_all = False
7- one_per_line = False
8- path = "."
9+ args = parser .parse_args ()
910
10- for arg in args :
11- if arg == "-a" :
12- show_all = True
13- elif arg == "-1" :
14- one_per_line = True
15- else :
16- path = arg
11+ files = sorted (os .listdir (args .path ))
1712
18- files = sorted ( os . listdir ( path ))
13+ files = [ f for f in files if args . all or not f . startswith ( "." )]
1914
20- for file in files :
21- if not show_all and file . startswith ( "." ) :
22- continue
23-
24- print (file )
15+ if args . one_per_line :
16+ for f in files :
17+ print ( f )
18+ else :
19+ print (" " . join ( files ) )
You can’t perform that action at this time.
0 commit comments