-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add --exclude-processing option #1963
Add --exclude-processing option #1963
Conversation
Hi @lliissoonngg, thanks for working on this. Before I review this fully, a couple things:
|
internal/cmd/main.go
Outdated
@@ -139,7 +139,8 @@ func InitFlags(command *cobra.Command) { | |||
command.Flags().StringP("in", "i", "", "Template `string` to process (alternative to --file and --input-dir)") | |||
command.Flags().String("input-dir", "", "`directory` which is examined recursively for templates (alternative to --file and --in)") | |||
|
|||
command.Flags().StringSlice("exclude", []string{}, "glob of files to not parse") | |||
command.Flags().StringSlice("exclude", []string{}, "glob of files to ignore") |
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 think the previous text was fine - "ignore" is somewhat ambiguous in this context
@assayire gently bump on this, could you take a look of the parameter naming in this PR? |
I am fine with the name. Quick question: If I have exclude say jpg and png, would I do |
No, |
Oops .. i think i typed it wrong. I meant to ask that if i have exclude multiple files from processing, would this work - |
Yes, multiple patterns works (exactly the same as |
If it works like
For something so verbose as this it would make more sense to use a config file, which would look like: excludeProcessing
- '*.jpg'
- '*.png'
- '*.gif' Hope that makes sense @assayire |
@lliissoonngg thanks for the updates. Can you please rebase? I've just merged #1336 which makes a large number of changes that will affect this. I'll make another review pass after that. |
Would it be also possible to exclude the processing of certain files even if "input" and "output" are not specified ( regardless of the copying operation)?
|
@tewfik-ghariani that command doesn't really make sense - |
Ah right, @hairyhenderson thanks for the clarification ^^ |
@hairyhenderson How would you specify it on command line to --exclude-processing? I mean the multiple files as you have specified in yaml. |
@assayire like I said:
|
6ef96f2
to
19caa0d
Compare
LGTM |
d8d4b2c
to
e8a4261
Compare
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 again for this contribution @lliissoonngg! I'm going to rebase and merge this now, and will work (later) on replacing the xignore
module.
35e489e
to
19b2ef4
Compare
Is this update released? |
@assayire, it doesn't look like it. This was merged on Feb 6 and the v3.11.7 release was published on Jan 23, which is a pity because I could really use this for my current project. 😞 @hairyhenderson any chance we can get a |
This is a new feature and as such is going in the next release, which will be v4. I could cut a v4.0.0-pre-3 pre-release if that helps. (also in general please don't pose questions on closed issues, they're very easy to miss!) |
Fixes #1911
This PR added a CLI option
--exclude-processing
and an equivelent config entryexcludeProcessing
, if it is set, the matching files will go with a different code pathcopyFileToOutDir
.To make the code reusable, the codes about file IO are offloaded from
fileToTemplate
intoreadInFile
,getOutfileHandler
, and are called bycopyFileToOutDir
as well.How to test:
Have a jpeg file in
in
directory.case 1: (test cli argument
--exclude-processing
)run:
./gomplate --exclude-processing '*.jpg' --input-dir=in --output-dir=out
the *.jpg exists in
out
directorycase 2: (test config file entry
excludeProcessing
)have a
.gomplate.yaml
file in the directory:`
inputDir: in/
outputDir: out/
excludeProcessing:
`
run:
./gomplate --input-dir=in --output-dir=out
the *.jpg exists in
out
directory