Skip to content

Commit

Permalink
Add support for embedding user local files as strings into the CUE va…
Browse files Browse the repository at this point in the history
…lue during load (#363)

Co-authored-by: Tony Worm <[email protected]>
  • Loading branch information
verdverm and Tony Worm authored May 4, 2024
1 parent 9a49fa7 commit 62a5718
Show file tree
Hide file tree
Showing 26 changed files with 350 additions and 143 deletions.
2 changes: 2 additions & 0 deletions .hof/shadow/cli/cmd/hof/flags/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type RootPflagpole struct {
IncludeData bool
WithContext bool
InjectEnv bool
UserFiles []string
AllErrors bool
IngoreErrors bool
Stats bool
Expand All @@ -37,6 +38,7 @@ func SetupRootPflags(fset *pflag.FlagSet, fpole *RootPflagpole) {
fset.BoolVarP(&(fpole.IncludeData), "include-data", "D", false, "auto include all data files found with cue files")
fset.BoolVarP(&(fpole.WithContext), "with-context", "", false, "add extra context for data files, usable in the -l/path flag")
fset.BoolVarP(&(fpole.InjectEnv), "inject-env", "V", false, "inject all ENV VARs as default tag vars")
fset.StringArrayVarP(&(fpole.UserFiles), "user-files", "U", nil, "file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before")
fset.BoolVarP(&(fpole.AllErrors), "all-errors", "E", false, "print all available errors")
fset.BoolVarP(&(fpole.IngoreErrors), "ignore-errors", "i", false, "turn off output and assume defaults at prompts")
fset.BoolVarP(&(fpole.Stats), "stats", "", false, "print generator statistics")
Expand Down
2 changes: 2 additions & 0 deletions cmd/hof/flags/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type RootPflagpole struct {
IncludeData bool
WithContext bool
InjectEnv bool
UserFiles []string
AllErrors bool
IngoreErrors bool
Stats bool
Expand All @@ -37,6 +38,7 @@ func SetupRootPflags(fset *pflag.FlagSet, fpole *RootPflagpole) {
fset.BoolVarP(&(fpole.IncludeData), "include-data", "D", false, "auto include all data files found with cue files")
fset.BoolVarP(&(fpole.WithContext), "with-context", "", false, "add extra context for data files, usable in the -l/path flag")
fset.BoolVarP(&(fpole.InjectEnv), "inject-env", "V", false, "inject all ENV VARs as default tag vars")
fset.StringArrayVarP(&(fpole.UserFiles), "user-files", "U", nil, "file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before")
fset.BoolVarP(&(fpole.AllErrors), "all-errors", "E", false, "print all available errors")
fset.BoolVarP(&(fpole.IngoreErrors), "ignore-errors", "i", false, "turn off output and assume defaults at prompts")
fset.BoolVarP(&(fpole.Stats), "stats", "", false, "print generator statistics")
Expand Down
7 changes: 7 additions & 0 deletions design/pflags.cue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ CliPflags: [...schema.Flag] & [ {
Type: "bool"
Default: ""
Help: "inject all ENV VARs as default tag vars"
}, {
Name: "UserFiles"
Long: "user-files"
Short: "U"
Type: "[]string"
Default: "nil"
Help: "file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before"
}, {
Name: "AllErrors"
Long: "all-errors"
Expand Down
29 changes: 15 additions & 14 deletions docs/code/cmd-help/chat
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@ Flags:
--topp float param: TopP (default 0.42)

Global Flags:
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag

Use "hof chat [command] --help" for more information about a command.
29 changes: 15 additions & 14 deletions docs/code/cmd-help/create
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ Flags:
-O, --outdir string base directory to write all output to

Global Flags:
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
29 changes: 15 additions & 14 deletions docs/code/cmd-help/dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,20 @@ Flags:
-M, --model stringArray specify one or more data models to operate on

Global Flags:
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag

Use "hof datamodel [command] --help" for more information about a command.
29 changes: 15 additions & 14 deletions docs/code/cmd-help/flow
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ Flags:
--progress print task progress as it happens

Global Flags:
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag

Use "hof flow [command] --help" for more information about a command.
29 changes: 15 additions & 14 deletions docs/code/cmd-help/fmt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ Flags:
-h, --help help for fmt

Global Flags:
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag

Use "hof fmt [command] --help" for more information about a command.
29 changes: 15 additions & 14 deletions docs/code/cmd-help/gen
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,20 @@ Flags:
-W, --watch-globs stringArray filepath globs to watch for changes and trigger full regen

Global Flags:
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag

Use "hof gen [command] --help" for more information about a command.
31 changes: 16 additions & 15 deletions docs/code/cmd-help/hof
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@ Additional commands:
feedback open an issue or discussion on GitHub

Flags:
-E, --all-errors print all available errors
-h, --help help for hof
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag
-E, --all-errors print all available errors
-h, --help help for hof
-i, --ignore-errors turn off output and assume defaults at prompts
-D, --include-data auto include all data files found with cue files
-V, --inject-env inject all ENV VARs as default tag vars
-I, --input stringArray extra data to unify into the root value
-p, --package string the Cue package context to use during execution
-l, --path stringArray CUE expression for single path component when placing data files
-q, --quiet turn off output and assume defaults at prompts
-d, --schema stringArray expression to select schema to apply to data files
--stats print generator statistics
-0, --stdin-empty A flag that ensure stdin is zero and does not block
-t, --tags stringArray @tags() to be injected into CUE code
-U, --user-files stringArray file globs to embed into the root value (<cue-path>=<file-glob>), use % as slash to trim before
-v, --verbosity int set the verbosity of output
--with-context add extra context for data files, usable in the -l/path flag

Use "hof [command] --help / -h" for more information about a command.

Loading

0 comments on commit 62a5718

Please sign in to comment.