-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_help.py
executable file
·57 lines (47 loc) · 1.02 KB
/
build_help.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
import subprocess
os.chdir(os.path.dirname(__file__))
commands = """\
mod
copy
replace
change-tag
vis
format
repair
cat
find
search
query
note-path"""
commands = [l.strip() for l in commands.split("\n") if l.strip()]
commands.insert(0, None)
helpmd = [
"# CLI Help",
(
"Not all alias commands are listed "
"(e.g., `grep` is an alias for `search --grep` and isn't included). "
"`query` is still included for the additional help. "
"`v1` is also excluded"
),
]
for command in commands:
name = command if command else "No Command"
helpmd.append(f"# {name}")
cmd = [sys.executable, "notefile.py"]
if command:
cmd.append(command)
cmd.append("--help")
help = (
subprocess.check_output(cmd).decode().replace("usage: notefile.py", "usage: notefile")
) # long comment
helpmd.append(
f"""
```text
{help}
```"""
)
with open("CLI_help.md", "wt") as f:
f.write("\n\n".join(helpmd))