inline
PARSER_STATE PARAM_ACTION<T>::Parse(int argc, char ** argv)
{
+if (argc == 0 ||
+ argv == NULL ||
+ *argv == NULL)
+ throw ERROR("Missing argument.");
T value;
if (str2x(*argv, value))
throw ERROR(std::string("Bad argument: '") + *argv + "'");
inline
PARSER_STATE PARAM_ACTION<std::string>::Parse(int argc, char ** argv)
{
+if (argc == 0 ||
+ argv == NULL ||
+ *argv == NULL)
+ throw ERROR("Missing argument.");
m_param = *argv;
return PARSER_STATE(false, --argc, ++argv);
}
PARSER_STATE CONFIG_ACTION::Parse(int argc, char ** argv)
{
+if (argc == 0 ||
+ argv == NULL ||
+ *argv == NULL)
+ throw ERROR("Missing argument.");
char * pos = strchr(*argv, '@');
if (pos != NULL)
{
.Add("w", "userpass", SGCONF::MakeParamAction(config.userPass, "<password>"), "\tpassword for the administrative login")
.Add("a", "address", SGCONF::MakeParamAction(config, "<connection string>"), "connection params as a single string in format: <login>:<password>@<host>:<port>");
-SGCONF::PARSER_STATE state(blocks.Parse(--argc, ++argv)); // Skipping self name
+
+SGCONF::PARSER_STATE state(false, argc, argv);
+
+try
+{
+state = blocks.Parse(--argc, ++argv); // Skipping self name
+}
+catch (const SGCONF::OPTION::ERROR& ex)
+{
+std::cerr << ex.what() << "\n";
+return -1;
+}
if (state.stop)
return 0;
}
catch (const ACTION::ERROR & ex)
{
- throw ERROR(m_longName + ": " + ex.what());
+ if (m_longName.empty())
+ throw ERROR("-" + m_shortName + ": " + ex.what());
+ else
+ throw ERROR("--" + m_longName + ", -" + m_shortName + ": " + ex.what());
}
}