feat: Add short output flag
Ref https://github.com/mr-karan/doggo/issues/35
This commit is contained in:
parent
7619cbdeb0
commit
eec8374e6f
6 changed files with 14 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue