parent
7619cbdeb0
commit
eec8374e6f
2
TODO.md
2
TODO.md
|
@ -62,7 +62,7 @@
|
|||
- [ ] Add tests for CLI Output.
|
||||
- [ ] Homebrew - Goreleaser
|
||||
- [ ] Add support for `dig +trace` like functionality.
|
||||
- [ ] Add `dig +x` short output
|
||||
- [ ] Add `dig +short` short output
|
||||
- [x] Add `--strategy` for picking nameservers.
|
||||
- [ ] Explore `dig.rc` kinda file
|
||||
- [x] Separate Authority/Answer in JSON output.
|
||||
|
|
|
@ -49,6 +49,7 @@ func main() {
|
|||
|
||||
// Output Options
|
||||
f.BoolP("json", "J", false, "Set the output format as JSON")
|
||||
f.Bool("short", false, "Short output format")
|
||||
f.Bool("time", false, "Display how long it took for the response to arrive")
|
||||
f.Bool("color", true, "Show colored output")
|
||||
f.Bool("debug", false, "Enable debug mode")
|
||||
|
|
|
@ -56,6 +56,7 @@ var appHelpTextTemplate = `{{ "NAME" | color "" "heading" }}:
|
|||
|
||||
{{ "Output Options" | color "" "heading" }}:
|
||||
{{"-J, --json " | color "yellow" ""}} Format the output as JSON.
|
||||
{{"--short" | color "yellow" ""}} Short output format. Shows only the response section.
|
||||
{{"--color " | color "yellow" ""}} Defaults to true. Set --color=false to disable colored output.
|
||||
{{"--debug " | color "yellow" ""}} Enable debug logging.
|
||||
{{"--time" | color "yellow" ""}} Shows how long the response took from the server.
|
||||
|
|
|
@ -21,6 +21,14 @@ func (app *App) outputJSON(rsp []resolvers.Response) {
|
|||
fmt.Printf("%s", res)
|
||||
}
|
||||
|
||||
func (app *App) outputShort(rsp []resolvers.Response) {
|
||||
for _, r := range rsp {
|
||||
for _, a := range r.Answers {
|
||||
fmt.Printf("%s\n", a.Address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) outputTerminal(rsp []resolvers.Response) {
|
||||
var (
|
||||
green = color.New(color.FgGreen, color.Bold).SprintFunc()
|
||||
|
@ -134,6 +142,8 @@ func (app *App) outputTerminal(rsp []resolvers.Response) {
|
|||
func (app *App) Output(responses []resolvers.Response) {
|
||||
if app.QueryFlags.ShowJSON {
|
||||
app.outputJSON(responses)
|
||||
} else if app.QueryFlags.ShortOutput {
|
||||
app.outputShort(responses)
|
||||
} else {
|
||||
app.outputTerminal(responses)
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ type QueryFlags struct {
|
|||
Color bool `koanf:"color" json:"-"`
|
||||
DisplayTimeTaken bool `koanf:"time" json:"-"`
|
||||
ShowJSON bool `koanf:"json" json:"-"`
|
||||
ShortOutput bool `koanf:"short" short:"-"`
|
||||
UseSearchList bool `koanf:"search" json:"-"`
|
||||
ReverseLookup bool `koanf:"reverse" reverse:"-"`
|
||||
Strategy string `koanf:"strategy" strategy:"-"`
|
||||
|
|
Loading…
Reference in New Issue