-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinventory_conditionals.py
More file actions
executable file
·53 lines (39 loc) · 1.38 KB
/
inventory_conditionals.py
File metadata and controls
executable file
·53 lines (39 loc) · 1.38 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
51
52
53
#!/usr/bin/env python3
"""
CLI tool to create an inventory of AsciiDoc conditional directives.
Scans .adoc files for ifdef, ifndef, endif, and ifeval directives
and creates a timestamped inventory file.
Usage:
inventory-conditionals [directory] [-o OUTPUT_DIR]
If no directory is specified, the current working directory is used.
"""
import argparse
from pathlib import Path
from doc_utils.inventory_conditionals import create_inventory
def main():
parser = argparse.ArgumentParser(
description='Create an inventory of AsciiDoc conditional directives.'
)
parser.add_argument(
'directory',
nargs='?',
default='.',
help='Directory to scan for .adoc files (default: current directory)'
)
parser.add_argument(
'-o', '--output-dir',
default=None,
help='Directory to write the inventory file (default: current directory)'
)
args = parser.parse_args()
directory = Path(args.directory).resolve()
if not directory.is_dir():
print(f"Error: {directory} is not a valid directory")
return 1
output_dir = Path(args.output_dir).resolve() if args.output_dir else Path.cwd()
print(f"Scanning for .adoc files in: {directory}")
output_file = create_inventory(directory, output_dir)
print(f"Inventory written to: {output_file}")
return 0
if __name__ == '__main__':
exit(main())