-
-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: When a config file is given, do not specify formatter on cli (terraform_docs) #386
Merged
antonbabenko
merged 5 commits into
antonbabenko:master
from
acodeninja:feat/allow-terraform-docs-config-to-specify-formatter
May 25, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bc1c2f6
feat: When a config file is given, do not specify formatter on cli
acodeninja 58f26a7
unset tf_docs_formatter variable instead of setting to empty
acodeninja 00b2639
Only set tf_docs_formatter if --config arg not included
acodeninja ace1460
Move to using regex for config test and align with reqs for = sign
acodeninja 855f9c5
Moved back to string contains syntax for bash v3
acodeninja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. Good point.
Can this
if
conditional be re-worked by adding check for--config
arg intocase
block on lines 125-135 and setting some var conditionally, e.g.config_file="true"
, and here instead ofif
statement do something like[[ $config_file != "true" ]] && local tf_docs_formatter="md"
? Thanks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I had a look at the case block which appears to be looking at the values in the
$hook_config
variable. This doesn't actually contain details passed in by the args property, those are contained in the$args
variable. I'm happy to alter the PR, but this doesn't appear to be the best way.Would something like this be ok?
I can of course break this up a little and do something like:
Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my bad. I indeed misread that part of code 🤦🏻
Yep
[[ "$args" != *"--config"* ]] && local tf_docs_formatter="md"
looks good to me. Thanks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's no worries, that was actually my first solution this morning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional statement may probably be improved a bit like this to cover short opt and to ensure the match is not a part of some other opt/value and to ensure this opt has a value (not sure whether one can put
between opt and its value though):
=
instead ofThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the short code I agree, however this currently isn't supported in any case. See line 19:
The absolute path resolution only kicks in if the full option
--config
is set. I can include this fix in my PR, but it feels out of scope. Happy to alter as required though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so
=
sign is allowed. Looks like we need to improve code on line 19 since it doesn't cover short options and space instead of equal sign 🤔 Though this indeed is out of scope of your PR. Let's pitch upon[[ ! $args =~ (^|[[:space:]])--config=[^[:space:]]+ ]] && local tf_docs_formatter="md"
so that these two are aligned?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[ "$args" != *"--config="* ]] && local tf_docs_formatter="md"
looks good too if you prefer it more =) (the only thing I'd like to ask to put is equal sign so that — again — the two bits of code aligned with each other)Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've swapped out for the regex approach so hopefully good to go.