Skip to content

Commit

Permalink
fix(cmd.RPC): warn when RPC connected
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Jun 15, 2018
1 parent 52c1d9e commit 00ff64f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions cmd/qri.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 00ff64f

Please sign in to comment.