1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

NEW FEATURE: Set JS variables from command line (#913)

* Add ability to specify variables that are passed to js

* Use SplitN to respect a = in value part

* Add JSON parsing for cli variables

* Remove JSON parsing for cli variables

* Add a function to set CLI defaults

* Update static.go
This commit is contained in:
Jan-Philipp Benecke
2020-10-27 15:43:00 +01:00
committed by GitHub
parent e51688c22d
commit 512aa7d4b3
5 changed files with 40 additions and 5 deletions

View File

@ -160,6 +160,7 @@ type ExecuteDSLArgs struct {
JSFile string
JSONFile string
DevMode bool
Variable cli.StringSlice
}
func (args *ExecuteDSLArgs) flags() []cli.Flag {
@ -182,6 +183,12 @@ func (args *ExecuteDSLArgs) flags() []cli.Flag {
Destination: &args.DevMode,
Usage: "Use helpers.js from disk instead of embedded copy",
},
&cli.StringSliceFlag{
Name: "variable",
Aliases: []string{"v"},
Destination: &args.Variable,
Usage: "Add variable that is passed to JS",
},
}
}