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