|
3 | 3 |
|
4 | 4 | based originally on click-man, but significantly specialized for the globus-cli
|
5 | 5 | """
|
| 6 | +import argparse |
| 7 | +import logging |
6 | 8 | import os
|
7 | 9 | import textwrap
|
8 | 10 | import time
|
|
16 | 18 | CLI = load_entry_point("globus-cli", "console_scripts", "globus")
|
17 | 19 | TARGET_DIR = os.path.dirname(__file__)
|
18 | 20 |
|
| 21 | +log = logging.getLogger(__name__) |
| 22 | + |
19 | 23 | try:
|
20 | 24 | # try to fetch last release date
|
21 | 25 | last_release = requests.get(
|
@@ -126,9 +130,11 @@ def __str__(self):
|
126 | 130 |
|
127 | 131 | def write_pages():
|
128 | 132 | for ctx in iter_all_commands():
|
129 |
| - if not isinstance(ctx.command, click.Group) and not getattr( |
130 |
| - ctx.command, "adoc_skip", True |
131 |
| - ): |
| 133 | + log.debug("write_pages() handling: '%s'", ctx.command_path) |
| 134 | + if not isinstance(ctx.command, click.Group): |
| 135 | + log.info( |
| 136 | + "write_pages() identified non-group command: '%s'", ctx.command_path |
| 137 | + ) |
132 | 138 | cmd_name = ctx.command_path.replace(" ", "_")[len("globus_") :]
|
133 | 139 | path = os.path.join(TARGET_DIR, cmd_name + ".adoc")
|
134 | 140 | with open(path, "w") as f:
|
@@ -160,6 +166,21 @@ def generate_index():
|
160 | 166 | f.write(ctx.command.get_short_help_str() + "\n\n")
|
161 | 167 |
|
162 | 168 |
|
163 |
| -if __name__ == "__main__": |
| 169 | +def main(): |
| 170 | + parser = argparse.ArgumentParser( |
| 171 | + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter |
| 172 | + ) |
| 173 | + parser.add_argument("--debug", help="enable debug logging", action="store_true") |
| 174 | + args = parser.parse_args() |
| 175 | + |
| 176 | + if args.debug: |
| 177 | + logging.basicConfig(level=logging.DEBUG) |
| 178 | + else: |
| 179 | + logging.basicConfig(level=logging.INFO) |
| 180 | + |
164 | 181 | write_pages()
|
165 | 182 | generate_index()
|
| 183 | + |
| 184 | + |
| 185 | +if __name__ == "__main__": |
| 186 | + main() |
0 commit comments