Repository: incubator-mynewt-newtmgr
Updated Branches:
  refs/heads/master 130b9ea9d -> 3cb138aba


Mynewt-693 - error check for type and connstring.
Print error when user does not provide type or connstring to newtmgr conn add 
command.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/commit/3187ae98
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/tree/3187ae98
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/diff/3187ae98

Branch: refs/heads/master
Commit: 3187ae981bda33465d478b0aaf1868ef7c763e82
Parents: 130b9ea
Author: cwanda <[email protected]>
Authored: Sun May 21 12:15:51 2017 -0700
Committer: cwanda <[email protected]>
Committed: Mon May 22 05:55:57 2017 -0700

----------------------------------------------------------------------
 newtmgr/cli/connprofile.go    | 13 ++++++++++++-
 newtmgr/config/connprofile.go |  3 ++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/3187ae98/newtmgr/cli/connprofile.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/connprofile.go b/newtmgr/cli/connprofile.go
index 5558156..864ddbd 100644
--- a/newtmgr/cli/connprofile.go
+++ b/newtmgr/cli/connprofile.go
@@ -23,8 +23,8 @@ import (
        "fmt"
        "strings"
 
-       "mynewt.apache.org/newtmgr/newtmgr/config"
        "mynewt.apache.org/newt/util"
+       "mynewt.apache.org/newtmgr/newtmgr/config"
 
        "github.com/spf13/cobra"
 )
@@ -40,6 +40,7 @@ func connProfileAddCmd(cmd *cobra.Command, args []string) {
        name := args[0]
        cp := config.NewConnProfile()
        cp.Name = name
+       cp.Type = config.CONN_TYPE_NONE
 
        for _, vdef := range args[1:] {
                s := strings.SplitN(vdef, "=", 2)
@@ -59,6 +60,16 @@ func connProfileAddCmd(cmd *cobra.Command, args []string) {
                }
        }
 
+       // Check that a type is specified.
+
+       if cp.Type == config.CONN_TYPE_NONE {
+               nmUsage(cmd, util.NewNewtError("Must specify a connection 
type"))
+       }
+
+       // Check that a connstring is specified.
+       if len(cp.ConnString) == 0 {
+               nmUsage(cmd, util.NewNewtError("Must specify a connection 
string"))
+       }
        if err := cpm.AddConnProfile(cp); err != nil {
                nmUsage(cmd, err)
        }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/3187ae98/newtmgr/config/connprofile.go
----------------------------------------------------------------------
diff --git a/newtmgr/config/connprofile.go b/newtmgr/config/connprofile.go
index da69695..51ff051 100644
--- a/newtmgr/config/connprofile.go
+++ b/newtmgr/config/connprofile.go
@@ -44,7 +44,8 @@ type ConnProfile struct {
 }
 
 const (
-       CONN_TYPE_SERIAL ConnType = iota
+       CONN_TYPE_NONE ConnType = iota
+       CONN_TYPE_SERIAL
        CONN_TYPE_BLE_PLAIN
        CONN_TYPE_BLE_OIC
        CONN_TYPE_UDP

Reply via email to