core: Refactor to use better cli command framework#177
Conversation
|
New requirement: This change can't break any TeamCity builds. The existing commands must work, or TC must be reconfigured to use commands that work in the old and new flags. Currently the commands used by TeamCity are: |
tlimoncelli
left a comment
There was a problem hiding this comment.
Generally looks good. My suggestion are mostly textual.
cmd/debugPreprocess.go
Outdated
| ) | ||
|
|
||
| var debugPreprocessCommand = &cli.Command{ | ||
| Name: "debug-preprocess", |
There was a problem hiding this comment.
Suggestion: s/debug-preprocess/output-ir/g
cmd/debugJs.go
Outdated
|
|
||
| var debugJSCommand = &cli.Command{ | ||
| Name: "debug-js", | ||
| Usage: "Execute javascript and print generated json", |
There was a problem hiding this comment.
s/Execute javascript and print generated json/Output intermediate representation (IR) after JavaScript is executed but before any validation/normalization/g
cmd/debugJs.go
Outdated
| } | ||
|
|
||
| var debugJSCommand = &cli.Command{ | ||
| Name: "debug-js", |
There was a problem hiding this comment.
s/debug-js/debug-otto/g
There was a problem hiding this comment.
I'd rather not mention otto in the command. There are other js interpreters I may evaluate and try to plug in in the future. otto is just one implementation.
cmd/debugPreprocess.go
Outdated
|
|
||
| var debugPreprocessCommand = &cli.Command{ | ||
| Name: "debug-preprocess", | ||
| Usage: "Run validation and normalization logic, and print resulting json", |
There was a problem hiding this comment.
Output intermediate representation (IR) after running validation and normalization logic.
build/validate/validate.go
Outdated
| return strings.Split(string(out), "\n"), nil | ||
| } | ||
|
|
||
| func checkDirectOutput() error { |
cmd/commands.go
Outdated
| cli.StringFlag{ | ||
| Name: "out", | ||
| Destination: &args.Output, | ||
| Usage: "File to write json to", |
There was a problem hiding this comment.
Set output file (default stdout)
cmd/commands.go
Outdated
| cli.StringFlag{ | ||
| Name: "domains", | ||
| Destination: &args.Domains, | ||
| Usage: `Comma seperated list of domain names to include`, |
There was a problem hiding this comment.
spell check: separated
| } | ||
| } | ||
|
|
||
| func (args *FilterArgs) shouldRunProvider(p string, dc *models.DomainConfig, nonDefaultProviders []string) bool { |
| return false | ||
| } | ||
|
|
||
| func (args *FilterArgs) shouldRunDomain(d string) bool { |
| return nil | ||
| } | ||
|
|
||
| // InitializeProviders takes a creds file path and a DNSConfig object. Creates all providers with the proper types, and returns them. |
There was a problem hiding this comment.
Comments should be limited to 80 cols.
| GetDNSConfigArgs | ||
| GetCredentialsArgs | ||
| FilterArgs | ||
| Delay int |
There was a problem hiding this comment.
PowerShell flags are missing: -fakeps, -psout, -pslog
|
We need to add a "dnscontrol check" which is like preview, but never talks to the providers. IT needs a way to check their work without having creds. A simple syntax check (plus normalize + validate) is sufficient. With the old system running "dnscontrol check" did this and we need to retain that. |
|
Pretty sure that check case is covered by |
9d67fda to
0609bf6
Compare
* starting to refactor commands * work * not sure * all commands working! * actually add file * work in delay flag again * start to refactor out console printing * i hate line endings * simple travis test to find direct output * remove all direct printing from push/preview * checkin vendor * don't need this yet * forgot to commit these * make version explicit command * some code review * Add "check" subcommand. * move stuff to commands package * fix * comment out check for printlns. for now * alphabet hax * activedir flags gone. use creds instead * active dir doc update * remove bind specific flags. creds instead * default to zones dir * fix linux build * fix test * cleanup random global* vars * Clean up PowerShell docs * rename dump-ir to print-ir. combine with print-js
This breaks up the command switching logic in main into explicit commands that can be run independently.
Uses https://github.com/urfave/cli as its cli library.