mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
Add --dest argument
This commit is contained in:
parent
debe93a82b
commit
cbd26b20c7
3 changed files with 10 additions and 5 deletions
|
|
@ -10,6 +10,9 @@ def main(argv=None):
|
|||
pulling the documentation from main.tf in order to replace the entire
|
||||
README.md file each time."""
|
||||
)
|
||||
parser.add_argument(
|
||||
'--dest', dest='dest', default='README.md',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--sort-inputs-by-required', dest='sort', action='store_true',
|
||||
)
|
||||
|
|
@ -21,7 +24,9 @@ def main(argv=None):
|
|||
|
||||
dirs = []
|
||||
for filename in args.filenames:
|
||||
if os.path.realpath(filename) not in dirs:
|
||||
if (os.path.realpath(filename) not in dirs and \
|
||||
len(os.path.realpath(filename).strip()) > 0 and \
|
||||
(filename.endswith(".tf") or filename.endswith(".tfvars"))):
|
||||
dirs.append(os.path.dirname(filename))
|
||||
|
||||
retval = 0
|
||||
|
|
@ -38,7 +43,7 @@ def main(argv=None):
|
|||
procArgs.append(dir)
|
||||
procArgs.append("| sed -e '$ d' -e 'N;/^\\n$/D;P;D'")
|
||||
procArgs.append('>')
|
||||
procArgs.append('{}/README.md'.format(dir))
|
||||
procArgs.append("./{dir}/{dest}".format(dir=dir,dest=args.dest))
|
||||
subprocess.check_call(" ".join(procArgs), shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue