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
|
#!/usr/bin/env python
"""Generate a global options section.
The purpose of this script is to pre-generate
global options for the help docs.
The output of this script is loaded and applied to
every subcommand's help docs.
"""
import os
from awscli.clidocs import (
EXAMPLES_DIR,
GLOBAL_OPTIONS_FILE,
GLOBAL_OPTIONS_SYNOPSIS_FILE,
GlobalOptionsDocumenter,
)
from awscli.clidriver import create_clidriver
def main():
if not os.path.isdir(EXAMPLES_DIR):
os.makedirs(EXAMPLES_DIR)
driver = create_clidriver()
options_help_command = driver.create_help_command()
synopsis_help_command = driver.create_help_command()
options_documenter = GlobalOptionsDocumenter(options_help_command)
synopsis_documenter = GlobalOptionsDocumenter(synopsis_help_command)
with open(GLOBAL_OPTIONS_FILE, 'w') as f:
for line in options_documenter.doc_global_options():
f.write(line)
with open(GLOBAL_OPTIONS_SYNOPSIS_FILE, 'w') as f:
for line in synopsis_documenter.doc_global_synopsis():
f.write(line)
if __name__ == "__main__":
main()
|