-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path,rm
executable file
·46 lines (35 loc) · 1.01 KB
/
,rm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = "Dilawar Singh"
__email__ = "[email protected]"
import os
import typing as T
from pathlib import Path
import typer
app = typer.Typer()
CACHE_DIR_ = Path(os.environ['HOME']) / '.cache' / 'iprm'
CACHE_DIR_.mkdir(parents=True, exist_ok=True)
def __show_trash(glob : str = '**'):
for f in Path(CACHE_DIR_).glob(glob):
print(f)
def __trash(paths : T.List[Path], dry_run:bool=False):
if dry_run:
print('[INFO] Following files will be deleted')
for path in paths:
if dry_run:
print(path)
else:
path.rename(CACHE_DIR_/path)
@app.command()
def main(paths : T.List[Path] = Path('.'), show_trash:bool=False, dry_run:bool=False):
for path in paths:
if path.exists():
__trash(path, dry_run)
return
if show_trash:
for p in paths:
__show_trash(p)
return
raise RuntimeWarning(f'{paths} does not exists')
if __name__ == '__main__':
app()