From 399d0a9a02d4a993b20637bebfba22f4c33aff04 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 6 May 2024 14:36:55 +0200 Subject: Reworking the cli manipulator a little bit --- modules/tools/examples/cli_mod.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'modules/tools/examples/cli_mod.cpp') diff --git a/modules/tools/examples/cli_mod.cpp b/modules/tools/examples/cli_mod.cpp index f108394..404b2ef 100644 --- a/modules/tools/examples/cli_mod.cpp +++ b/modules/tools/examples/cli_mod.cpp @@ -83,12 +83,14 @@ int main(int argc, char** argv){ return min_amount_args; }else if (args_view.at(1) == "w"){ return min_amount_args + 1u; + }else if (args_view.at(1) == "l"){ + return min_amount_args; } return 0u; }(); if(args_size < min_amount_args){ - std::cerr<<"Invalid first argument. Must either be 'r' or 'w'"< bool { - if(args_view.at(1) == "w"){ - return false; - } - return true; + std::string_view mode = [&]() -> std::string_view { + return args_view.at(1); }(); std::string json_data; - if ( not is_read_mode ){ + if ( mode == "w" ){ json_data = std::string{args_view.at(4)}; } std::deque sch_path = split_schema_path(args_view.at(3)); { - auto eov = saw::modify_data_on_cli(is_read_mode, args_view.at(2), sch_path, json_data); + auto eov = saw::modify_data_on_cli(mode, args_view.at(2), sch_path, json_data); if(eov.is_error()){ auto& err = eov.get_error(); std::cerr<<"Modification failed: "<