Catch parameter errors on startup and display option informations
This commit is contained in:
parent
c0bc7b6644
commit
cccb07c7cd
12
src/main.cc
12
src/main.cc
|
@ -362,6 +362,18 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
kakoune(params);
|
kakoune(params);
|
||||||
}
|
}
|
||||||
|
catch (Kakoune::parameter_error& error)
|
||||||
|
{
|
||||||
|
printf("Error: %s\n"
|
||||||
|
"Valid options:\n"
|
||||||
|
" -e <commands>: execute commands on initialisation\n"
|
||||||
|
" -c <session>: connect to the given session\n"
|
||||||
|
" -s <session>: set session name\n"
|
||||||
|
" -d: run as a headless session (requires -s)\n"
|
||||||
|
" -n: do not source kakrc files on startup\n",
|
||||||
|
error.what());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
catch (Kakoune::exception& error)
|
catch (Kakoune::exception& error)
|
||||||
{
|
{
|
||||||
on_assert_failed(("uncaught exception:\n"_str + error.what()).c_str());
|
on_assert_failed(("uncaught exception:\n"_str + error.what()).c_str());
|
||||||
|
|
|
@ -12,21 +12,26 @@ namespace Kakoune
|
||||||
|
|
||||||
using ParameterList = memoryview<String>;
|
using ParameterList = memoryview<String>;
|
||||||
|
|
||||||
struct unknown_option : public runtime_error
|
struct parameter_error : public runtime_error
|
||||||
|
{
|
||||||
|
using runtime_error::runtime_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct unknown_option : public parameter_error
|
||||||
{
|
{
|
||||||
unknown_option(const String& name)
|
unknown_option(const String& name)
|
||||||
: runtime_error("unknown option '" + name + "'") {}
|
: parameter_error("unknown option '" + name + "'") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct missing_option_value: public runtime_error
|
struct missing_option_value: public parameter_error
|
||||||
{
|
{
|
||||||
missing_option_value(const String& name)
|
missing_option_value(const String& name)
|
||||||
: runtime_error("missing value for option '" + name + "'") {}
|
: parameter_error("missing value for option '" + name + "'") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wrong_argument_count : runtime_error
|
struct wrong_argument_count : public parameter_error
|
||||||
{
|
{
|
||||||
wrong_argument_count() : runtime_error("wrong argument count") {}
|
wrong_argument_count() : parameter_error("wrong argument count") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using OptionMap = std::unordered_map<String, bool>;
|
using OptionMap = std::unordered_map<String, bool>;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user