From 00ff64f8a2f99f8e7f19fa7b81225c960521041a Mon Sep 17 00:00:00 2001 From: b5 Date: Fri, 15 Jun 2018 16:38:35 -0400 Subject: [PATCH] fix(cmd.RPC): warn when RPC connected --- cmd/qri.go | 21 ++++++++++++++------- cmd/search.go | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cmd/qri.go b/cmd/qri.go index 69c5ec0f6..69dc5382f 100644 --- a/cmd/qri.go +++ b/cmd/qri.go @@ -116,14 +116,17 @@ func (o *QriOptions) init() (err error) { return } o.config = core.Config + setNoColor(!o.config.CLI.ColorizeOutput || o.NoColor) - addr := fmt.Sprintf(":%d", o.config.RPC.Port) - if conn, err := net.Dial("tcp", addr); err != nil { - err = nil - } else { - o.rpc = rpc.NewClient(conn) - return + if o.config.RPC.Enabled { + addr := fmt.Sprintf(":%d", o.config.RPC.Port) + if conn, err := net.Dial("tcp", addr); err != nil { + err = nil + } else { + o.rpc = rpc.NewClient(conn) + return + } } // for now this just checks for an existing config file @@ -188,7 +191,11 @@ func (o *QriOptions) RPC() *rpc.Client { // Repo returns from internal state func (o *QriOptions) Repo() (repo.Repo, error) { - return o.repo, o.init() + err := o.init() + if o.repo == nil { + return nil, fmt.Errorf("repo not available (are you running qri in another terminal?)") + } + return o.repo, err } // DatasetRequests generates a core.DatasetRequests from internal state diff --git a/cmd/search.go b/cmd/search.go index 0b31ef38e..af6d6fc06 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -17,7 +17,7 @@ func NewSearchCommand(f Factory, ioStreams IOStreams) *cobra.Command { Short: "Search qri", Long: `Search datasets & peers that match your query`, Annotations: map[string]string{ - "group": "other", + "group": "network", }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) {