You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/05/17 18:15:32 UTC
[GitHub] mkiiskila closed pull request #76: nmxact;
add option to include save command as part of config write.
mkiiskila closed pull request #76: nmxact; add option to include save command as part of config write.
URL: https://github.com/apache/mynewt-newtmgr/pull/76
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/newtmgr/cli/config.go b/newtmgr/cli/config.go
index 0891245..d860839 100644
--- a/newtmgr/cli/config.go
+++ b/newtmgr/cli/config.go
@@ -67,6 +67,24 @@ func configWrite(s sesn.Sesn, args []string) {
}
}
+func configSave(s sesn.Sesn, args []string) {
+ c := xact.NewConfigWriteCmd()
+ c.SetTxOptions(nmutil.TxOptions())
+ c.Save = true
+
+ res, err := c.Run(s)
+ if err != nil {
+ nmUsage(nil, util.ChildNewtError(err))
+ }
+
+ sres := res.(*xact.ConfigWriteResult)
+ if sres.Rsp.Rc != 0 {
+ fmt.Printf("Error: %d\n", sres.Rsp.Rc)
+ } else {
+ fmt.Printf("Done\n")
+ }
+}
+
func configRunCmd(cmd *cobra.Command, args []string) {
s, err := GetSesn()
if err != nil {
@@ -74,7 +92,11 @@ func configRunCmd(cmd *cobra.Command, args []string) {
}
if len(args) == 1 {
- configRead(s, args)
+ if args[0] == "save" {
+ configSave(s, args)
+ } else {
+ configRead(s, args)
+ }
} else if len(args) >= 2 {
configWrite(s, args)
} else {
diff --git a/nmxact/nmp/config.go b/nmxact/nmp/config.go
index dc00df5..18830fc 100644
--- a/nmxact/nmp/config.go
+++ b/nmxact/nmp/config.go
@@ -56,8 +56,9 @@ func (r *ConfigReadRsp) Msg() *NmpMsg { return MsgFromReq(r) }
type ConfigWriteReq struct {
NmpBase
- Name string `codec:"name"`
- Val string `codec:"val"`
+ Name string `codec:"name",omitempty`
+ Val string `codec:"val",omitempty`
+ Save bool `codec:"save",omitempty`
}
type ConfigWriteRsp struct {
diff --git a/nmxact/xact/config.go b/nmxact/xact/config.go
index c5b172b..12eaff7 100644
--- a/nmxact/xact/config.go
+++ b/nmxact/xact/config.go
@@ -74,6 +74,7 @@ type ConfigWriteCmd struct {
CmdBase
Name string
Val string
+ Save bool
}
func NewConfigWriteCmd() *ConfigWriteCmd {
@@ -98,6 +99,7 @@ func (c *ConfigWriteCmd) Run(s sesn.Sesn) (Result, error) {
r := nmp.NewConfigWriteReq()
r.Name = c.Name
r.Val = c.Val
+ r.Save = c.Save
rsp, err := txReq(s, r.Msg(), &c.CmdBase)
if err != nil {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services