22import os
33import glob
44import foxylint .imports
5+ import foxylint .loggingcase
56
67
78def red (text ):
@@ -12,11 +13,7 @@ def bold(text):
1213 return click .secho (text , fg = 'white' , bold = True )
1314
1415
15- @click .command ()
16- @click .argument ('files' , nargs = - 1 , type = click .Path ())
17- @click .option ('--exclude' , '-e' , multiple = True )
18- @click .option ('--accept' , multiple = True )
19- def main (files , exclude , accept ):
16+ def _find_files (files , exclude ):
2017 excluded = []
2118 for pattern in exclude :
2219 excluded .extend (glob .glob (pattern , recursive = True ))
@@ -29,8 +26,10 @@ def main(files, exclude, accept):
2926 if os .path .abspath (file ) not in excluded :
3027 files .append (file )
3128
32- accept = [pattern .strip ('/' ) for pattern in accept ]
33- findings = foxylint .imports .analyze (files , acceptable_patterns = accept )
29+ return files
30+
31+
32+ def _show_findings (findings ):
3433 bad_files = 0
3534 for file , analysis in findings .items ():
3635 if analysis ['ok' ]:
@@ -45,3 +44,31 @@ def main(files, exclude, accept):
4544 quit (1 )
4645 else :
4746 quit (0 )
47+
48+
49+ @click .group ()
50+ @click .pass_context
51+ def main (context ):
52+ pass
53+
54+
55+ @main .command ()
56+ @click .pass_context
57+ @click .argument ('files' , nargs = - 1 , type = click .Path ())
58+ @click .option ('--exclude' , '-e' , multiple = True )
59+ @click .option ('--accept' , multiple = True )
60+ def imports (context , files , exclude , accept ):
61+ files = _find_files (files , exclude )
62+ accept = [pattern .strip ('/' ) for pattern in accept ]
63+ findings = foxylint .imports .analyze (files , acceptable_patterns = accept )
64+ _show_findings (findings )
65+
66+
67+ @main .command ()
68+ @click .pass_context
69+ @click .argument ('files' , nargs = - 1 , type = click .Path ())
70+ @click .option ('--exclude' , '-e' , multiple = True )
71+ def loggingcase (context , files , exclude ):
72+ files = _find_files (files , exclude = exclude )
73+ findings = foxylint .loggingcase .analyze (files )
74+ _show_findings (findings )
0 commit comments