File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 1- import sys
1+ import glob
2+ from itertools import chain
3+ from os .path import isfile
24
35import filetype
46
@@ -17,20 +19,22 @@ def main():
1719 parser = argparse .ArgumentParser (
1820 prog = 'filetype' , description = 'Determine type of FILEs.'
1921 )
20- parser .add_argument ('-f' , '--file' , nargs = '+' )
22+ parser .add_argument (
23+ 'file' , nargs = '+' ,
24+ help = 'files, wildcard is supported'
25+ )
2126 parser .add_argument (
2227 '-v' , '--version' , action = 'version' ,
23- version = '%(prog)s ' + filetype .version ,
28+ version = f '%(prog)s { filetype .version } ' ,
2429 help = 'output version information and exit'
2530 )
2631
2732 args = parser .parse_args ()
28- if len (sys .argv ) < 2 :
29- parser .print_help ()
30- sys .exit (1 )
33+ items = chain .from_iterable (map (glob .iglob , args .file ))
34+ files = filter (isfile , items )
3135
32- for i in args . file :
33- guess (i )
36+ for file in files :
37+ guess (file )
3438
3539
3640if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments