Add a -version switch to Kakoune

Closes #1035
This commit is contained in:
Maxime Coste 2018-08-09 11:24:11 +02:00
parent ae75032936
commit f706b8c9be

View File

@ -914,6 +914,7 @@ int main(int argc, char* argv[])
{ "l", { false, "list existing sessions" } }, { "l", { false, "list existing sessions" } },
{ "clear", { false, "clear dead sessions" } }, { "clear", { false, "clear dead sessions" } },
{ "debug", { true, "initial debug option value" } }, { "debug", { true, "initial debug option value" } },
{ "version", { false, "display kakoune version and exit" } },
{ "ro", { false, "readonly mode" } }, { "ro", { false, "readonly mode" } },
{ "help", { false, "display a help message and quit" } } } { "help", { false, "display a help message and quit" } } }
}; };
@ -945,6 +946,12 @@ int main(int argc, char* argv[])
if (show_help_message) if (show_help_message)
return show_usage(); return show_usage();
if (parser.get_switch("version"))
{
write_stdout(format("Kakoune {}\n", Kakoune::version));
return 0;
}
const bool list_sessions = (bool)parser.get_switch("l"); const bool list_sessions = (bool)parser.get_switch("l");
const bool clear_sessions = (bool)parser.get_switch("clear"); const bool clear_sessions = (bool)parser.get_switch("clear");
if (list_sessions or clear_sessions) if (list_sessions or clear_sessions)