release cmd/config

Merge remote-tracking branch 'upstream/master' into release-cmd/config-v0.0
This commit is contained in:
Phillip Wittrock
2020-01-13 12:47:01 -08:00
20 changed files with 377 additions and 89 deletions

View File

@@ -43,6 +43,26 @@ Advanced Documentation Topics:
`,
}
// Export commands publicly for composition
var (
Cat = commands.CatCommand
Count = commands.CountCommand
CreateSetter = commands.CreateSetterCommand
Fmt = commands.FmtCommand
Grep = commands.GrepCommand
ListSetters = commands.ListSettersCommand
Merge = commands.MergeCommand
Merge3 = commands.Merge3Command
RunFn = commands.RunFnCommand
Set = commands.SetCommand
Sink = commands.SinkCommand
Source = commands.SourceCommand
Tree = commands.TreeCommand
StackOnError = &commands.StackOnError
ExitOnError = &commands.ExitOnError
)
// NewConfigCommand returns a new *cobra.Command for the config command group. This may
// be embedded into other go binaries as a way of packaging the "config" command as part
// of another binary.

View File

@@ -27,6 +27,8 @@ func GetRunFnRunner(name string) *RunFnRunner {
r.Command = c
r.Command.Flags().BoolVar(
&r.DryRun, "dry-run", false, "print results to stdout")
r.Command.Flags().BoolVar(
&r.GlobalScope, "global-scope", false, "set global scope for functions.")
r.Command.Flags().StringSliceVar(
&r.FnPaths, "fn-path", []string{},
"directories containing functions without configuration")
@@ -44,11 +46,12 @@ type RunFnRunner struct {
IncludeSubpackages bool
Command *cobra.Command
DryRun bool
GlobalScope bool
FnPaths []string
}
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
rec := runfn.RunFns{Path: args[0], FunctionPaths: r.FnPaths}
rec := runfn.RunFns{Path: args[0], FunctionPaths: r.FnPaths, GlobalScope: r.GlobalScope}
if r.DryRun {
rec.Output = c.OutOrStdout()
}