Make help message generation robust.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
from io import StringIO
|
||||
import sys
|
||||
|
||||
from iottb import DOCS_FOLDER
|
||||
# Import your CLI app here
|
||||
from iottb.main import cli
|
||||
|
||||
@@ -28,7 +30,7 @@ def get_help_text(command):
|
||||
|
||||
def write_help_to_file(cli, filename):
|
||||
"""Write help messages of all commands and subcommands to a file."""
|
||||
with open(filename, 'w') as f:
|
||||
with open(filename, 'w+') as f:
|
||||
# main
|
||||
f.write(f"Main Command: iottb\n")
|
||||
f.write(get_help_text(cli))
|
||||
@@ -49,4 +51,9 @@ def write_help_to_file(cli, filename):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
write_help_to_file(cli, "help_messages.md")
|
||||
from iottb import DOCS_FOLDER
|
||||
print('Must be in project root for this to work properly!')
|
||||
print(f'CWD is {str(Path.cwd())}')
|
||||
DOCS_FOLDER.mkdir(exist_ok=True)
|
||||
write_help_to_file(cli, str(DOCS_FOLDER / "help_messages.md"))
|
||||
print(f'Wrote help_messages.md to {str(DOCS_FOLDER / "help_messages.md")}')
|
||||
|
||||
Reference in New Issue
Block a user