1212
1313
1414def populate_argument_parser (subcommand_parser : ArgumentParser ) -> None :
15+ """Populate the parser for the subcommand."""
1516 subcommand_parser .description = (
1617 'Run terraform-docs on a set of files. Follows the standard '
1718 'convention of pulling the documentation from main.tf in order to '
@@ -47,13 +48,19 @@ def populate_argument_parser(subcommand_parser: ArgumentParser) -> None:
4748
4849
4950def invoke_cli_app (parsed_cli_args : Namespace ) -> ReturnCodeType :
51+ """Run the entry-point of the CLI app.
52+
53+ Returns:
54+ ReturnCodeType: The return code of the app.
55+ """
5056 warnings .warn (
5157 '`terraform_docs_replace` hook is DEPRECATED.'
5258 'For migration instructions see '
5359 'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
5460 '#issuecomment-1290829226' ,
5561 category = UserWarning ,
56- stacklevel = 1 , # It's should be 2, but tests are failing w/ values >1. As it's deprecated hook, it's safe to leave it as is w/o fixing it later.
62+ stacklevel = 1 , # It's should be 2, but tests are failing w/ values >1.
63+ # As it's deprecated hook, it's safe to leave it as is w/o fixing it.
5764 )
5865
5966 dirs : list [str ] = []
@@ -65,24 +72,24 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
6572
6673 retval = ReturnCode .OK
6774
68- for dir in dirs :
75+ for directory in dirs :
6976 try :
70- procArgs = []
71- procArgs .append ('terraform-docs' )
77+ proc_args = []
78+ proc_args .append ('terraform-docs' )
7279 if cast_to ('bool' , parsed_cli_args .sort ):
73- procArgs .append ('--sort-by-required' )
74- procArgs .extend (
80+ proc_args .append ('--sort-by-required' )
81+ proc_args .extend (
7582 (
7683 'md' ,
77- f'./{ dir } ' ,
84+ f'./{ directory } ' ,
7885 '>' ,
7986 './{dir}/{dest}' .format (
80- dir = dir ,
87+ dir = directory ,
8188 dest = cast_to ('str' , parsed_cli_args .dest ),
8289 ),
8390 ),
8491 )
85- subprocess .check_call (' ' .join (procArgs ), shell = True )
92+ subprocess .check_call (' ' .join (proc_args ), shell = True )
8693 except subprocess .CalledProcessError as e :
8794 print (e )
8895 retval = ReturnCode .ERROR
0 commit comments