-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path01_cli_usage.py
More file actions
70 lines (50 loc) · 1.89 KB
/
01_cli_usage.py
File metadata and controls
70 lines (50 loc) · 1.89 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Example 1: CLI Usage - Generate documentation from command line.
This example demonstrates how to use code2docs from the command line
to generate documentation for your project.
"""
# =============================================================================
# BASIC CLI USAGE
# =============================================================================
# Generate README.md for current directory
# $ code2docs .
# Generate with specific output
# $ code2docs ./my_project --output docs/
# Generate only README (skip other docs)
# $ code2docs . --readme-only
# Dry run - preview what would be generated
# $ code2docs . --dry-run
# =============================================================================
# ADVANCED CLI OPTIONS
# =============================================================================
# Watch mode - auto-regenerate on file changes
# $ code2docs . --watch
# Sync mode - update only changed sections
# $ code2docs . --sync
# Custom config file
# $ code2docs . --config my-code2docs.yaml
# Verbose output
# $ code2docs . -v
# =============================================================================
# PYTHON API: CLI Programmatically
# =============================================================================
import subprocess
def run_cli_basic(project_path: str) -> None:
"""Run code2docs CLI programmatically."""
result = subprocess.run(
["code2docs", project_path, "--output", "docs/"],
capture_output=True,
text=True
)
print(f"Exit code: {result.returncode}")
print(f"Output: {result.stdout}")
def run_cli_with_config(project_path: str, config_path: str) -> None:
"""Run with custom configuration."""
subprocess.run([
"code2docs", project_path,
"--config", config_path,
"--readme-only"
], check=True)
if __name__ == "__main__":
# Example usage
# run_cli_basic("./my_project")
pass