mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 01:11:36 +03:00
Refactor, remove kakoune function and move it inside main.
This commit is contained in:
parent
ceb10665d1
commit
eff32aa1a1
56
src/main.cc
56
src/main.cc
@ -440,8 +440,32 @@ int run_pipe(StringView session)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kakoune(const ParametersParser& parser)
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
signal(SIGSEGV, signal_handler);
|
||||
signal(SIGFPE, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
|
||||
std::vector<String> params;
|
||||
for (size_t i = 1; i < argc; ++i)
|
||||
params.push_back(argv[i]);
|
||||
|
||||
const ParameterDesc param_desc{
|
||||
SwitchMap{ { "c", { true, "connect to given session" } },
|
||||
{ "e", { true, "execute argument on initialisation" } },
|
||||
{ "n", { false, "do not source kakrc files on startup" } },
|
||||
{ "s", { true, "set session name" } },
|
||||
{ "d", { false, "run as a headless session (requires -s)" } },
|
||||
{ "p", { true, "just send stdin as commands to the given session" } },
|
||||
{ "f", { true, "act as a filter, executing given keys on given files" } } }
|
||||
};
|
||||
try
|
||||
{
|
||||
ParametersParser parser(params, param_desc);
|
||||
|
||||
if (parser.has_option("p"))
|
||||
{
|
||||
for (auto opt : { "c", "n", "s", "d", "e" })
|
||||
@ -493,40 +517,14 @@ int kakoune(const ParametersParser& parser)
|
||||
parser.has_option("n"),
|
||||
files);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
signal(SIGSEGV, signal_handler);
|
||||
signal(SIGFPE, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
|
||||
std::vector<String> params;
|
||||
for (size_t i = 1; i < argc; ++i)
|
||||
params.push_back(argv[i]);
|
||||
|
||||
const ParameterDesc param_desc{
|
||||
SwitchMap{ { "c", { true, "connect to given session" } },
|
||||
{ "e", { true, "execute argument on initialisation" } },
|
||||
{ "n", { false, "do not source kakrc files on startup" } },
|
||||
{ "s", { true, "set session name" } },
|
||||
{ "d", { false, "run as a headless session (requires -s)" } },
|
||||
{ "p", { true, "just send stdin as commands to the given session" } },
|
||||
{ "f", { true, "act as a filter, executing given keys on given files" } } }
|
||||
};
|
||||
try
|
||||
{
|
||||
kakoune(ParametersParser(params, param_desc));
|
||||
}
|
||||
catch (Kakoune::parameter_error& error)
|
||||
{
|
||||
printf("Error: %s\n"
|
||||
"Valid switches:\n"
|
||||
"%s",
|
||||
error.what(), generate_switches_doc(param_desc.switches).c_str());
|
||||
error.what(),
|
||||
generate_switches_doc(param_desc.switches).c_str());
|
||||
return -1;
|
||||
}
|
||||
catch (Kakoune::exception& error)
|
||||
|
Loading…
Reference in New Issue
Block a user