pvxput handle JSON

disable CLI for 3.15
This commit is contained in:
Michael Davidsaver committed 2026-06-28 11:47:57 -07:00
1 parent 2b99e3c6ee
commit 8cb8d4bf69
3 files changed
+24 -6

No files matched your search

+18 -5
View File
@@ -12,8 +12,11 @@
#include <epicsGetopt.h>
#include <epicsThread.h>
#define PVXS_ENABLE_EXPERT_API
#include <pvxs/client.h>
#include <pvxs/log.h>
#include <pvxs/json.h>
#include "utilpvt.h"
#include "evhelper.h"
@@ -85,9 +88,10 @@ int main(int argc, char *argv[])
if(argc-optind==1 && std::string(argv[optind]).find_first_of('=')==std::string::npos) {
// only one field assignment, and field name omitted.
// implies .value
// if JSON map, treat as entire struct. Others imply .value
values["value"] = argv[optind];
auto sval(argv[optind]);
values[sval[0]=='{' ? "" : "value"] = sval;
} else {
for(auto n : range(optind, argc)) {
@@ -120,9 +124,18 @@ int main(int argc, char *argv[])
val.unmark(false, true);
for(auto& pair : values) {
try{
val[pair.first] = pair.second;
}catch(NoConvert& e){
throw std::runtime_error(SB()<<"Unable to assign "<<pair.first<<" from \""<<escape(pair.second)<<"\"");
auto fld(val);
if(!pair.first.empty())
fld = val.lookup(pair.first);
auto& sv(pair.second);
if(!sv.empty() && (sv[0]=='{' || sv[0]=='[' || sv[0]=='"'))
json::Parse(pair.second).into(fld);
else
fld.from(sv);
}catch(std::exception& e){
throw std::runtime_error(SB()<<"Unable to assign "<<pair.first
<<" from \""<<escape(pair.second)<<"\""
<<" : "<<e.what());
}
}
if(verbose) {