X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7766e753fefb962209f1898a234053f8c7bbe59d..0c097ef3435d2a45c1ee4ac80f8bd3f254fb8df5:/projects/sgconf/api_action.cpp?ds=sidebyside diff --git a/projects/sgconf/api_action.cpp b/projects/sgconf/api_action.cpp index 1ff0e596..d5b1e8e6 100644 --- a/projects/sgconf/api_action.cpp +++ b/projects/sgconf/api_action.cpp @@ -1,8 +1,9 @@ #include "api_action.h" +#include "actions.h" #include "parser_state.h" -SGCONF::PARSER_STATE SGCONF::API_ACTION::Parse(int argc, char ** argv) +SGCONF::PARSER_STATE SGCONF::API_ACTION::Parse(int argc, char ** argv, void * /*data*/) { PARSER_STATE state(false, argc, argv); if (!m_argument.empty()) @@ -15,7 +16,25 @@ if (!m_argument.empty()) --state.argc; ++state.argv; } -m_suboptions.Parse(state.argc, state.argv); +state = m_suboptions.Parse(state.argc, state.argv, &m_params); m_commands.Add(m_funPtr, m_argument, m_params); return state; } + +SGCONF::API_ACTION::API_ACTION(COMMANDS & commands, + const std::string & paramDescription, + bool needArgument, + const std::vector & params, + API_FUNCTION funPtr) + : m_commands(commands), + m_description(paramDescription), + m_argument(needArgument ? "1" : ""), // Hack + m_funPtr(funPtr) +{ +std::vector::const_iterator it(params.begin()); +while (it != params.end()) + { + m_suboptions.Add(it->name, MakeKVAction(it->name, it->shortDescr), it->longDescr); + ++it; + } +}