nerd_tree/src/cmdline_parser.py

34 lines
1.1 KiB
Python
Raw Normal View History

2024-01-29 14:07:09 +01:00
import argparse
from pathlib import Path
cmd_parser = argparse.ArgumentParser(
prog='vfind',
description='A visual version of unix find command in which the results are shown in a tree',
epilog="Thanks for using it! :)",
)
cmd_parser.add_argument("path")
cmd_parser.add_argument("pattern")
2024-02-05 10:10:00 +01:00
cmd_parser.add_argument("-t", "--type")
2024-01-29 14:07:09 +01:00
# if -s is found in the command line cmd_args.show_children_nodes is True
cmd_parser.add_argument("-s", "--show-children-nodes", action="store_true")
2024-03-12 11:41:29 +01:00
cmd_parser.add_argument("-S", "--show-subtree-info", action="store_true")
2024-01-31 12:00:38 +01:00
## more than one occurrencies of -e option are appended in a list
cmd_parser.add_argument("-e", "--exclude", action="append")
2024-01-29 14:07:09 +01:00
# supporting regular expression otherwise use shell expansions
cmd_parser.add_argument("-re", "--regular-expression", action="store_true")
2024-02-22 09:40:24 +01:00
cmd_parser.add_argument("-i", "--include", action="append")
2024-01-29 14:07:09 +01:00
# start the command line parsing
cmd_args = cmd_parser.parse_args()
p = cmd_args.path
path = Path(p)
if not path.exists():
print(f'Path: {p} dont\' exists')
raise SystemExit(1)