Skip to content

Commit

Permalink
add a number of flags for upcoming changes
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Worm <tony@hofstadter.io>
  • Loading branch information
verdverm committed Oct 16, 2021
1 parent b38d044 commit 049fdc7
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .hof/shadow/Cli/cmd/cuetils/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ var cuetilsLong = `CUE Utilites for bulk ETL, diff, query, and other operations
func init() {

RootCmd.PersistentFlags().IntVarP(&(flags.RootPflags.Maxiter), "maxiter", "m", 0, "maximum iterations for recursion")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Concrete), "concrete", "c", false, "enforce concrete outputs")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Definitions), "definitions", "D", true, "process definitions in inputs and objects")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Hidden), "hidden", "H", true, "process hidden fields in inputs and objects")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Optional), "optional", "O", true, "process optional fields in inputs and objects")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.LoadOperator), "load-operator", "", true, "use cue/load to support entrypoint and imports in the operator")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.LoadOperands), "load-operands", "", false, "use cue/load to support entrypoint and imports in the operands")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Headers), "headers", "", false, "print the filename as a header during output")
RootCmd.PersistentFlags().StringVarP(&(flags.RootPflags.Accum), "accum", "", "<filepath>.<ext>", "accumulate operand results into a single value using accum as the label")
RootCmd.PersistentFlags().StringVarP(&(flags.RootPflags.Out), "out", "", "cue", "output encoding [cue,yaml,json]")
RootCmd.PersistentFlags().StringVarP(&(flags.RootPflags.Outname), "outname", "", "<filepath>.<ext>", "output filename when being used")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Overwrite), "overwrite", "", false, "overwrite files being processed")
}

func RootPersistentPostRun(args []string) (err error) {
Expand Down
14 changes: 12 additions & 2 deletions .hof/shadow/Cli/cmd/cuetils/flags/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ func PrintSubject(title, prefix, subject string, subjects map[string]string) boo
}

type RootPflagpole struct {
Maxiter int
Out string
Maxiter int
Concrete bool
Definitions bool
Hidden bool
Optional bool
LoadOperator bool
LoadOperands bool
Headers bool
Accum string
Out string
Outname string
Overwrite bool
}

var RootPflags RootPflagpole
10 changes: 10 additions & 0 deletions cmd/cuetils/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ var cuetilsLong = `CUE Utilites for bulk ETL, diff, query, and other operations
func init() {

RootCmd.PersistentFlags().IntVarP(&(flags.RootPflags.Maxiter), "maxiter", "m", 0, "maximum iterations for recursion")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Concrete), "concrete", "c", false, "enforce concrete outputs")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Definitions), "definitions", "D", true, "process definitions in inputs and objects")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Hidden), "hidden", "H", true, "process hidden fields in inputs and objects")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Optional), "optional", "O", true, "process optional fields in inputs and objects")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.LoadOperator), "load-operator", "", true, "use cue/load to support entrypoint and imports in the operator")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.LoadOperands), "load-operands", "", false, "use cue/load to support entrypoint and imports in the operands")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Headers), "headers", "", false, "print the filename as a header during output")
RootCmd.PersistentFlags().StringVarP(&(flags.RootPflags.Accum), "accum", "", "<filepath>.<ext>", "accumulate operand results into a single value using accum as the label")
RootCmd.PersistentFlags().StringVarP(&(flags.RootPflags.Out), "out", "", "cue", "output encoding [cue,yaml,json]")
RootCmd.PersistentFlags().StringVarP(&(flags.RootPflags.Outname), "outname", "", "<filepath>.<ext>", "output filename when being used")
RootCmd.PersistentFlags().BoolVarP(&(flags.RootPflags.Overwrite), "overwrite", "", false, "overwrite files being processed")
}

func RootPersistentPostRun(args []string) (err error) {
Expand Down
14 changes: 12 additions & 2 deletions cmd/cuetils/flags/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ func PrintSubject(title, prefix, subject string, subjects map[string]string) boo
}

type RootPflagpole struct {
Maxiter int
Out string
Maxiter int
Concrete bool
Definitions bool
Hidden bool
Optional bool
LoadOperator bool
LoadOperands bool
Headers bool
Accum string
Out string
Outname string
Overwrite bool
}

var RootPflags RootPflagpole
64 changes: 64 additions & 0 deletions gen.cue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,76 @@ Cli: gen.#HofGenerator & {
Type: "int"
Default: ""
Help: "maximum iterations for recursion"
},{
Name: "concrete"
Long: "concrete"
Short: "c"
Type: "bool"
Default: "false"
Help: "enforce concrete outputs"
},{
Name: "definitions"
Long: "definitions"
Short: "D"
Type: "bool"
Default: "true"
Help: "process definitions in inputs and objects"
},{
Name: "hidden"
Long: "hidden"
Short: "H"
Type: "bool"
Default: "true"
Help: "process hidden fields in inputs and objects"
},{
Name: "optional"
Long: "optional"
Short: "O"
Type: "bool"
Default: "true"
Help: "process optional fields in inputs and objects"
},{
Name: "loadOperator"
Long: "load-operator"
Type: "bool"
Default: "true"
Help: "use cue/load to support entrypoint and imports in the operator"
},{
Name: "loadOperands"
Long: "load-operands"
Type: "bool"
Default: "false"
Help: "use cue/load to support entrypoint and imports in the operands"
},{
Name: "headers"
Long: "headers"
Type: "bool"
Default: "false"
Help: "print the filename as a header during output"
},{
Name: "accum"
Long: "accum"
Type: "string"
Default: "\"<filepath>.<ext>\""
Help: "accumulate operand results into a single value using accum as the label"
},{
Name: "out"
Long: "out"
Type: "string"
Default: "\"cue\""
Help: "output encoding [cue,yaml,json]"
},{
Name: "outname"
Long: "outname"
Type: "string"
Default: "\"<filepath>.<ext>\""
Help: "output filename when being used"
},{
Name: "overwrite"
Long: "overwrite"
Type: "bool"
Default: "false"
Help: "overwrite files being processed"
}]

//
Expand Down

0 comments on commit 049fdc7

Please sign in to comment.