forked from noahgift/python-devops-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgcli.py
More file actions
27 lines (23 loc) · 677 Bytes
/
Copy pathgcli.py
File metadata and controls
27 lines (23 loc) · 677 Bytes
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
#!/usr/bin/env python
import click
import glob
@click.command()
@click.option(
"--path",
prompt="Path to search for files",
help="This is the path to search for files: /tmp",
)
@click.option(
"--ftype",
prompt="Pass in the type of file",
help="Pass in the file type: i.e csv"
)
def search(path, ftype):
"""Search for files of a specific type in a given path."""
results = glob.glob(f"{path}/*.{ftype}")
click.echo(click.style("Found Matches:", fg="red"))
for result in results:
click.echo(click.style(f"{result}", bg="blue", fg="white"))
if __name__ == "__main__":
# pylint: disable=no-value-for-parameter
search()