From 22ae7244297c3b63cfb8f44e3a9be52286e629df Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Thu, 9 Aug 2018 16:52:21 -0400 Subject: Adding --chmod flag to explicitly set output file modes Signed-off-by: Dave Henderson --- cmd/gomplate/main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/gomplate/main.go b/cmd/gomplate/main.go index bde6eb46..c0ba8909 100644 --- a/cmd/gomplate/main.go +++ b/cmd/gomplate/main.go @@ -93,22 +93,27 @@ func newGomplateCmd() *cobra.Command { } func initFlags(command *cobra.Command) { - command.Flags().BoolVarP(&printVer, "version", "v", false, "print the version") + command.Flags().SortFlags = false + + command.Flags().StringArrayVarP(&opts.DataSources, "datasource", "d", nil, "`datasource` in alias=URL form. Specify multiple times to add multiple sources.") + command.Flags().StringArrayVarP(&opts.DataSourceHeaders, "datasource-header", "H", nil, "HTTP `header` field in 'alias=Name: value' form to be provided on HTTP-based data sources. Multiples can be set.") command.Flags().StringArrayVarP(&opts.InputFiles, "file", "f", []string{"-"}, "Template `file` to process. Omit to use standard input, or use --in or --input-dir") command.Flags().StringVarP(&opts.Input, "in", "i", "", "Template `string` to process (alternative to --file and --input-dir)") command.Flags().StringVar(&opts.InputDir, "input-dir", "", "`directory` which is examined recursively for templates (alternative to --file and --in)") + command.Flags().StringArrayVar(&opts.ExcludeGlob, "exclude", []string{}, "glob of files to not parse") + command.Flags().StringArrayVarP(&opts.OutputFiles, "out", "o", []string{"-"}, "output `file` name. Omit to use standard output.") command.Flags().StringVar(&opts.OutputDir, "output-dir", ".", "`directory` to store the processed templates. Only used for --input-dir") - - command.Flags().StringArrayVarP(&opts.DataSources, "datasource", "d", nil, "`datasource` in alias=URL form. Specify multiple times to add multiple sources.") - command.Flags().StringArrayVarP(&opts.DataSourceHeaders, "datasource-header", "H", nil, "HTTP `header` field in 'alias=Name: value' form to be provided on HTTP-based data sources. Multiples can be set.") + command.Flags().StringVar(&opts.OutMode, "chmod", "", "set the mode for output file(s). Omit to inherit from input file(s)") ldDefault := env.Getenv("GOMPLATE_LEFT_DELIM", "{{") rdDefault := env.Getenv("GOMPLATE_RIGHT_DELIM", "}}") command.Flags().StringVar(&opts.LDelim, "left-delim", ldDefault, "override the default left-`delimiter` [$GOMPLATE_LEFT_DELIM]") command.Flags().StringVar(&opts.RDelim, "right-delim", rdDefault, "override the default right-`delimiter` [$GOMPLATE_RIGHT_DELIM]") + + command.Flags().BoolVarP(&printVer, "version", "v", false, "print the version") } func main() { -- cgit v1.2.3