This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new bc272f6  Add `newt target config flat` command
bc272f6 is described below

commit bc272f6e3903bc429a6e8c7aef764974301fbb4c
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Fri Jan 25 17:03:21 2019 -0800

    Add `newt target config flat` command
    
    This command prints a simple listing of all syscfg values in the target.
    E.g.,
    
        [ccollins@ccollins:~/proj/myproj]$ newt target config flat my_blinky_sim
        APP_NAME: "blinky"
        APP_blinky: 1
        ARCH_NAME: "sim"
        ARCH_sim: 1
        BSP_NAME: "native"
        BSP_SIMULATED: 1
        # <...>
    
    The output of this command can be diffed against an earlier version to
    detect changes in a target's syscfg.
---
 newt/cli/target_cfg_cmds.go | 56 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/newt/cli/target_cfg_cmds.go b/newt/cli/target_cfg_cmds.go
index 6966519..4bbb2a0 100644
--- a/newt/cli/target_cfg_cmds.go
+++ b/newt/cli/target_cfg_cmds.go
@@ -153,7 +153,8 @@ func printBriefCfg(targetName string, cfg syscfg.Cfg) {
                util.StatusMessage(util.VERBOSITY_DEFAULT, "!!! %s\n\n", 
errText)
        }
 
-       util.StatusMessage(util.VERBOSITY_DEFAULT, "Brief syscfg for %s:\n", 
targetName)
+       util.StatusMessage(util.VERBOSITY_DEFAULT,
+               "Brief syscfg for %s:\n", targetName)
        pkgNameEntryMap := syscfg.EntriesByPkg(cfg)
 
        pkgNames := make([]string, 0, len(pkgNameEntryMap))
@@ -170,6 +171,24 @@ func printBriefCfg(targetName string, cfg syscfg.Cfg) {
        }
 }
 
+func printFlatCfg(targetName string, cfg syscfg.Cfg) {
+       if errText := cfg.ErrorText(); errText != "" {
+               util.StatusMessage(util.VERBOSITY_DEFAULT, "!!! %s\n\n", 
errText)
+       }
+
+       settings := cfg.SettingValues()
+       names := make([]string, 0, len(settings))
+       for name, _ := range settings {
+               names = append(names, name)
+       }
+       sort.Strings(names)
+
+       for _, name := range names {
+               util.StatusMessage(util.VERBOSITY_DEFAULT,
+                       "%s: %s\n", name, settings[name])
+       }
+}
+
 func yamlPkgCfg(w io.Writer, pkgName string, cfg syscfg.Cfg,
        entries []syscfg.CfgEntry) {
 
@@ -271,6 +290,29 @@ func targetConfigBriefCmd(cmd *cobra.Command, args 
[]string) {
        }
 }
 
+func targetConfigFlatCmd(cmd *cobra.Command, args []string) {
+       if len(args) < 1 {
+               NewtUsage(cmd,
+                       util.NewNewtError("Must specify target or unittest 
name"))
+       }
+
+       TryGetProject()
+
+       for i, arg := range args {
+               b, err := TargetBuilderForTargetOrUnittest(arg)
+               if err != nil {
+                       NewtUsage(cmd, err)
+               }
+
+               res := targetBuilderConfigResolve(b)
+               printFlatCfg(b.GetTarget().Name(), res.Cfg)
+
+               if i < len(args)-1 {
+                       util.StatusMessage(util.VERBOSITY_DEFAULT, "\n")
+               }
+       }
+}
+
 func valSettingString(vs val.ValSetting) string {
        intVal, _ := vs.IntVal()
 
@@ -725,6 +767,18 @@ func targetCfgCmdAll() []*cobra.Command {
                return append(targetList(), unittestList()...)
        })
 
+       configFlatCmd := &cobra.Command{
+               Use:   "flat <target> [target...]",
+               Short: "View a flat table of target's system configuration",
+               Long:  "View a flat table of target's system configuration",
+               Run:   targetConfigFlatCmd,
+       }
+
+       configCmd.AddCommand(configFlatCmd)
+       AddTabCompleteFn(configFlatCmd, func() []string {
+               return append(targetList(), unittestList()...)
+       })
+
        configInitCmd := &cobra.Command{
                Use:   "init",
                Short: "Populate a target's system configuration file",

Reply via email to