22from os .path import exists , isdir
33from shutil import rmtree
44
5- import click
5+ from click import echo , style
66
77
88__version__ = "0.0.1-dev0"
99
1010
11- @click .command ()
12- @click .help_option ("--help" , "-h" )
13- @click .option ("--verbose" , "-v" , is_flag = True , default = False )
14- @click .option ("--version" , "-V" , is_flag = True , default = False )
15- @click .argument ("PATH" , nargs = - 1 , type = click .Path ())
16- def main (path , verbose , version ):
17- """This utility is meant for use in makefiles as the clean target or similar usecases.
18- It takes an arbitray number of PATH objects and removes them if they exists.
19- Folders will be remove recursivly."""
20- if version :
21- print (f"makeclean.py v{ __version__ } " )
22- return
23- clean (path , verbose )
24-
25-
26- def clean (path : list [str | PathLike ], verbose = False ):
11+ def clean (path : list [str | PathLike ], verbose = False ):
2712 """Removes all given Path-Objects, meaning files are deleted and
2813 directorys are removed recurlivly.
2914
@@ -34,15 +19,15 @@ def clean(path: list[str|PathLike], verbose=False):
3419 for p in path :
3520 if not exists (p ):
3621 if verbose :
37- click . echo (f'{ click . style ("skip" , fg = "yellow" )} : { p } ' )
22+ echo (f'{ style ("skip" , fg = "yellow" )} : { p } ' )
3823 continue
3924 if isdir (p ):
4025 if not p .endswith ("/" ):
4126 p += "/"
4227 if verbose :
43- click . echo (f'{ click . style ("dir" , fg = "bright_cyan" )} : { p } ' )
28+ echo (f'{ style ("dir" , fg = "bright_cyan" )} : { p } ' )
4429 rmtree (p )
4530 else :
4631 if verbose :
47- click . echo (f'{ click . style ("file" , fg = "blue" )} : { p } ' )
32+ echo (f'{ style ("file" , fg = "blue" )} : { p } ' )
4833 remove (p )
0 commit comments