-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcli.py
More file actions
50 lines (46 loc) · 1.29 KB
/
cli.py
File metadata and controls
50 lines (46 loc) · 1.29 KB
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
47
48
49
50
"""This module provides the RP Tree CLI."""
import argparse
import sys
from . import __version__
def parse_cmd_line_arguments() -> argparse.Namespace:
parser = argparse.ArgumentParser(
prog="tree",
description="RP Tree, a directory tree diagram generator",
epilog="Thanks for using RP Tree!",
)
parser.add_argument(
"-v",
"--version",
action="version",
version=f"RP Tree v{__version__}",
help="displays the version of RP Tree",
)
parser.add_argument(
"root_dir",
metavar="ROOT_DIR",
nargs="?",
default=".",
help="generates a directory tree diagram starting at ROOT_DIR",
)
parser.add_argument(
"-d",
"--dir-only",
action="store_true",
help="generates a directory-only (no files) tree diagram",
)
parser.add_argument(
"-o",
"--output-file",
metavar="OUTPUT_FILE",
nargs="?",
default=sys.stdout,
help="saves the directory tree diagram to OUTPUT_FILE in Markdown format",
)
parser.add_argument(
"--depth",
type=int,
metavar="N",
default=None,
help="limits the depth of the directory tree diagram to N levels",
)
return parser.parse_args()