Merge remote-tracking branch 'lenormf/fix-help-flag'

This commit is contained in:
Maxime Coste 2017-04-10 20:28:55 +01:00
commit f6eea456d4
2 changed files with 28 additions and 3 deletions

View File

@ -7,7 +7,7 @@ kak - a vim inspired, selection oriented code editor
SYNOPSIS SYNOPSIS
-------- --------
*kak* [-q] [-n] [-l] [-ro] [-clear] [-ui ui_type] [-e command] [-f keys] [-p session_id] [-c session_id|[[-d] -s session_id] [+line[:column]] file ... *kak* [-help] [-q] [-n] [-l] [-ro] [-clear] [-ui ui_type] [-e command] [-f keys] [-p session_id] [-c session_id|[[-d] -s session_id] [+line[:column]|+:] file ...
DESCRIPTION DESCRIPTION
----------- -----------
@ -26,6 +26,9 @@ stays fixed and the cursor one moves around.
OPTIONS OPTIONS
------- -------
-help::
display a help message and quit
-n:: -n::
do not load resource files on startup ('kakrc', 'autoload', 'rc' etc) do not load resource files on startup ('kakrc', 'autoload', 'rc' etc)
@ -63,7 +66,8 @@ OPTIONS
enter in 'readonly mode', all the buffers opened will not be written to disk enter in 'readonly mode', all the buffers opened will not be written to disk
+line[:column]:: +line[:column]::
specify a target line and column for the first file specify a target line and column for the first file; when the plus sign is followed by only a colon,
then the cursor is sent to the last line of the file
file:: file::
one or more files to edit one or more files to edit

View File

@ -801,12 +801,33 @@ int main(int argc, char* argv[])
{ "ui", { true, "set the type of user interface to use (ncurses, dummy, or json)" } }, { "ui", { true, "set the type of user interface to use (ncurses, dummy, or json)" } },
{ "l", { false, "list existing sessions" } }, { "l", { false, "list existing sessions" } },
{ "clear", { false, "clear dead sessions" } }, { "clear", { false, "clear dead sessions" } },
{ "ro", { false, "readonly mode" } } } { "ro", { false, "readonly mode" } },
{ "help", { false, "display a help message and quit" } } }
}; };
try try
{ {
auto show_usage = [&]()
{
write_stdout(format("Usage: {} [options] [file]... [+<line>[:<col>]|+:]\n\n"
"Options:\n"
"{}\n"
"Prefixing a positional argument with a plus (`+`) sign will place the\n"
"cursor at a given set of coordinates, or the end of the buffer if the plus\n"
"sign is followed only by a colon (`:`)\n",
argv[0], generate_switches_doc(param_desc.switches)));
return 0;
};
if (contains(ConstArrayView<char*>{argv+1, (size_t)argc-1}, StringView{"--help"}))
return show_usage();
ParametersParser parser(params, param_desc); ParametersParser parser(params, param_desc);
const bool show_help_message = (bool)parser.get_switch("help");
if (show_help_message)
return show_usage();
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)