11import os
22import subprocess
33import warnings
4- from argparse import ArgumentParser , Namespace
4+ from argparse import ArgumentParser
5+ from argparse import Namespace
56from typing import Final
67
78from ._structs import ReturnCode
89from ._types import ReturnCodeType
910
10-
1111CLI_SUBCOMMAND_NAME : Final [str ] = 'replace-docs'
1212
1313
@@ -18,14 +18,20 @@ def populate_argument_parser(subcommand_parser: ArgumentParser) -> None:
1818 'replace the entire README.md file each time.'
1919 )
2020 subcommand_parser .add_argument (
21- '--dest' , dest = 'dest' , default = 'README.md' ,
21+ '--dest' ,
22+ dest = 'dest' ,
23+ default = 'README.md' ,
2224 )
2325 subcommand_parser .add_argument (
24- '--sort-inputs-by-required' , dest = 'sort' , action = 'store_true' ,
26+ '--sort-inputs-by-required' ,
27+ dest = 'sort' ,
28+ action = 'store_true' ,
2529 help = '[deprecated] use --sort-by-required instead' ,
2630 )
2731 subcommand_parser .add_argument (
28- '--sort-by-required' , dest = 'sort' , action = 'store_true' ,
32+ '--sort-by-required' ,
33+ dest = 'sort' ,
34+ action = 'store_true' ,
2935 )
3036 subcommand_parser .add_argument (
3137 '--with-aggregate-type-defaults' ,
@@ -51,8 +57,9 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
5157
5258 dirs = []
5359 for filename in parsed_cli_args .filenames :
54- if (os .path .realpath (filename ) not in dirs and
55- (filename .endswith (".tf" ) or filename .endswith (".tfvars" ))):
60+ if os .path .realpath (filename ) not in dirs and (
61+ filename .endswith ('.tf' ) or filename .endswith ('.tfvars' )
62+ ):
5663 dirs .append (os .path .dirname (filename ))
5764
5865 retval = ReturnCode .OK
@@ -64,13 +71,12 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
6471 if parsed_cli_args .sort :
6572 procArgs .append ('--sort-by-required' )
6673 procArgs .append ('md' )
67- procArgs .append (" ./{dir}" .format (dir = dir ))
74+ procArgs .append (' ./{dir}' .format (dir = dir ))
6875 procArgs .append ('>' )
6976 procArgs .append (
70- './{dir}/{dest}' .
71- format (dir = dir , dest = parsed_cli_args .dest ),
77+ './{dir}/{dest}' .format (dir = dir , dest = parsed_cli_args .dest ),
7278 )
73- subprocess .check_call (" " .join (procArgs ), shell = True )
79+ subprocess .check_call (' ' .join (procArgs ), shell = True )
7480 except subprocess .CalledProcessError as e :
7581 print (e )
7682 retval = ReturnCode .ERROR
0 commit comments