diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go index edd975763..70903abbf 100644 --- a/cmd/cmd_test.go +++ b/cmd/cmd_test.go @@ -166,8 +166,8 @@ func TestCommandsIntegration(t *testing.T) { fmt.Sprintf("qri save --body=%s me/movies", moviesFilePath), fmt.Sprintf("qri save --body=%s me/movies2", movies2FilePath), fmt.Sprintf("qri save --body=%s me/links", linksFilepath), - "qri info me/movies", "qri list", + "qri list me/movies", fmt.Sprintf("qri save --body=%s -t=commit_1 me/movies", movies2FilePath), "qri log me/movies", "qri diff me/movies me/movies2 -d=detail", diff --git a/cmd/info.go b/cmd/info.go deleted file mode 100644 index 12faef64a..000000000 --- a/cmd/info.go +++ /dev/null @@ -1,132 +0,0 @@ -package cmd - -import ( - "encoding/json" - "fmt" - - "github.com/qri-io/dataset" - "github.com/qri-io/ioes" - "github.com/qri-io/qri/lib" - "github.com/qri-io/qri/repo" - "github.com/spf13/cobra" -) - -// NewInfoCommand creates a `qri info` cobra command for describing datasets -func NewInfoCommand(f Factory, ioStreams ioes.IOStreams) *cobra.Command { - o := &InfoOptions{IOStreams: ioStreams} - cmd := &cobra.Command{ - Use: "info", - Aliases: []string{"get", "describe"}, - Short: "Show summarized description of a dataset", - Long: `Info describes datasets. By default, it will return the peername, dataset name, -the network, the dataset hash, the file size, the length of the datasets, -and the validation errors. - -Using the ` + "`--format`" + ` flag, you can get output in json. This will return a json -representation of the dataset, without the dataset body, identical to -` + "`qri get --format json`" + `. - -To get info on a peer's dataset, you must be running ` + "`qri connect`" + ` in a separate -terminal window.`, - Example: ` # get info for my dataset: - qri info me/annual_pop - - # get info for a dataset at a specific version: - qri info me@/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn - - or - - qri info me/comics@/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn - - # get info in json format - qri info -f json me/annual_pop - - # to get info on a peer's dataset, spin up your qri node - qri connect - - # then, in a separate window, request the info from peer b5 - qri info b5/comics`, - Annotations: map[string]string{ - "group": "dataset", - }, - RunE: func(cmd *cobra.Command, args []string) error { - if err := o.Complete(f, args); err != nil { - return err - } - return o.Run() - }, - } - - cmd.Flags().StringVarP(&o.Format, "format", "f", "", "set output format [json]") - return cmd -} - -// InfoOptions encapsulates state for the info command -type InfoOptions struct { - ioes.IOStreams - - Refs []string - Format string - - DatasetRequests *lib.DatasetRequests -} - -// Complete adds any missing configuration that can only be added just before calling Run -func (o *InfoOptions) Complete(f Factory, args []string) (err error) { - o.Refs = args - o.DatasetRequests, err = f.DatasetRequests() - return -} - -// Run executes the info command -func (o *InfoOptions) Run() error { - if o.Format != "" { - format, err := dataset.ParseDataFormatString(o.Format) - if err != nil { - return fmt.Errorf("invalid data format: %s", o.Format) - } - if format != dataset.JSONDataFormat { - return fmt.Errorf("invalid data format. currently only json or plaintext are supported") - } - } - - if len(o.Refs) == 0 { - return o.info(0, "") - } - - for i, refstr := range o.Refs { - if err := o.info(i, refstr); err != nil { - return err - } - } - - return nil -} - -// info prints terse information about a single dataset -func (o *InfoOptions) info(index int, refstr string) (err error) { - - p := lib.GetParams{ - Path: refstr, - } - res := lib.GetResult{} - if err = o.DatasetRequests.Get(&p, &res); err != nil { - if err == repo.ErrEmptyRef { - return lib.NewError(err, "please provide a dataset reference") - } - return err - } - - if o.Format == "" { - // TODO (b5): refactor to work with dataset.Dataset instead - ref := repo.DatasetRef{Peername: res.Dataset.Peername, Name: res.Dataset.Name, Dataset: res.Dataset} - printDatasetRefInfo(o.Out, index, ref) - } else { - data, err := json.MarshalIndent(res.Dataset, "", " ") - if err != nil { - return err - } - fmt.Fprintf(o.Out, "%s", string(data)) - } - return nil -} diff --git a/cmd/qri.go b/cmd/qri.go index 8b43fbe88..5bd9f4a0b 100644 --- a/cmd/qri.go +++ b/cmd/qri.go @@ -57,7 +57,6 @@ https://github.com/qri-io/qri/issues`, NewDiffCommand(opt, ioStreams), NewExportCommand(opt, ioStreams), NewGetCommand(opt, ioStreams), - NewInfoCommand(opt, ioStreams), NewListCommand(opt, ioStreams), NewLogCommand(opt, ioStreams), NewManifestCommand(opt, ioStreams),