Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions pkg/cmd/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ import (
"github.com/vulncheck-oss/cli/pkg/ui"
)

type Options struct {
Full bool
}

func Command() *cobra.Command {

opts := &Options{
Full: false,
}

cmd := &cobra.Command{
Use: "index <command>",
Short: i18n.C.IndexShort,
Expand Down Expand Up @@ -62,7 +70,15 @@ func Command() *cobra.Command {
if err != nil {
return err
}
ui.Json(response.GetData())

var terminalOutput interface{}
terminalOutput = response.GetData()
if opts.Full {
terminalOutput = response
}

ui.Json(terminalOutput)

return nil
},
}
Expand Down Expand Up @@ -99,11 +115,21 @@ func Command() *cobra.Command {
if err != nil {
return err
}
ui.Viewport(args[0], response.GetData())

var viewportOutput interface{}
viewportOutput = response.GetData()
if opts.Full {
viewportOutput = response
}
ui.Viewport(args[0], viewportOutput)

return nil
},
}

cmdList.Flags().BoolVarP(&opts.Full, "full", "f", false, i18n.C.IndexFlagFullResponse)
cmdBrowse.Flags().BoolVarP(&opts.Full, "full", "f", false, i18n.C.IndexFlagFullResponse)

cmd.AddCommand(cmdList)
cmd.AddCommand(cmdBrowse)

Expand Down
18 changes: 10 additions & 8 deletions pkg/i18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ type Copy struct {
BrowseIndicesSearch string
BrowseIndicesFull string

IndexShort string
IndexListShort string
IndexBrowseShort string
IndexErrorRequired string
IndexShort string
IndexListShort string
IndexBrowseShort string
IndexErrorRequired string
IndexFlagFullResponse string

BackupShort string
BackupUrlShort string
Expand Down Expand Up @@ -220,10 +221,11 @@ var En = Copy{
BrowseIndicesSearch: "Listing %d indices searching for \"%s\"",
BrowseIndicesFull: "Listing %d indices",

IndexShort: "Browse or list an index",
IndexListShort: "List documents of a specified index",
IndexBrowseShort: "Browse documents of an index interactively",
IndexErrorRequired: "index name is required",
IndexShort: "Browse or list an index",
IndexListShort: "List documents of a specified index",
IndexBrowseShort: "Browse documents of an index interactively",
IndexErrorRequired: "index name is required",
IndexFlagFullResponse: "Output full response",

BackupShort: "Download a backup of a specified index",
BackupUrlShort: "Get the temporary signed URL of the backup of an index",
Expand Down
Loading