You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/22 14:30:49 UTC

[mynewt-newt] 02/02: Add single state config for syscfg

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

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

commit 763d5c03eea359eae9359ce03080466ccc030441
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Mar 22 11:05:18 2022 +0100

    Add single state config for syscfg
    
    This can be used intead of separate settings for each state.
---
 newt/syscfg/syscfg.go | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index ae30e9e..985cae9 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -463,6 +463,24 @@ func readSetting(name string, lpkg *pkg.LocalPackage,
 		entry.State = CFG_SETTING_STATE_GOOD
 	}
 
+	stateVal, stateExist := vals["state"]
+	if stateExist {
+		if entry.State != CFG_SETTING_STATE_GOOD {
+			util.OneTimeWarning("Setting %s has duplicated state definition, using \"state\".", name)
+		}
+
+		switch stringValue(stateVal) {
+		case "defunct":
+			entry.State = CFG_SETTING_STATE_DEFUNCT
+		case "deprecated":
+			entry.State = CFG_SETTING_STATE_DEPRECATED
+		case "experimental":
+			entry.State = CFG_SETTING_STATE_EXPERIMENTAL
+		default:
+			util.OneTimeWarning("Invalid \"state\" for setting %s, assuming regular state.", name)
+		}
+	}
+
 	// The value field for setting definition is required.
 	valueVal, valueExist := vals["value"]
 	if valueExist {