summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/query-config19
1 files changed, 12 insertions, 7 deletions
diff --git a/scripts/query-config b/scripts/query-config
index cfd26cc3..23e64ef7 100755
--- a/scripts/query-config
+++ b/scripts/query-config
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# File: query-config
-# Purpose: Extracts field values from the build config,
+# Purpose: Extracts field values a flat JSON file,
# for use in languages that can't handle JSON easily,
# (I'm looking at you, Bourne shell!)
@@ -25,12 +25,17 @@ import json
import defaults
import util
-if len(sys.argv) < 2:
- print("Usage: {0} <config field name>".format(sys.argv[0]))
+if len(sys.argv) < 3:
+ print("Usage: {0} <flat JSON file> <config field name>".format(sys.argv[0]))
sys.exit(1)
-util.check_build_config()
-with open(defaults.BUILD_CONFIG, 'r') as f:
- build_config = json.load(f)
+# Note: lack of error handling is deliberate, if some field is expected to be there
+# but isn't, it's better if the failure will be obvious and spectacular
-print(build_config[sys.argv[1]])
+file = sys.argv[1]
+key = sys.argv[2]
+
+with open(file, 'r') as f:
+ json_data = json.load(f)
+
+print(json_data[key])