Add long description option to usage.
Introduce a new usage/6 that allows a long description to be
specified, which allows for usage output that documents structured
command lines using not just short/long options. For example,
commands like the following:
$ command group <group_name> create
Paul Fisher
7 years ago
11 | 11 | -author('juanjo@comellas.org'). |
12 | 12 | |
13 | 13 | -export([parse/2, check/2, parse_and_check/2, format_error/2, |
14 | usage/2, usage/3, usage/4, tokenize/1]). | |
14 | usage/2, usage/3, usage/4, usage/6, tokenize/1]). | |
15 | 15 | -export([usage_cmd_line/2]). |
16 | 16 | |
17 | 17 | -define(LINE_LENGTH, 75). |
572 | 572 | usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, OutputStream) -> |
573 | 573 | io:format(OutputStream, "~ts~n~n~ts~n", |
574 | 574 | [unicode:characters_to_list(usage_cmd_line(ProgramName, OptSpecList, CmdLineTail)), unicode:characters_to_list(usage_options(OptSpecList, OptionsTail))]). |
575 | ||
576 | %% @doc Show a message on standard_error or standard_io indicating the | |
577 | %% command line options and arguments that are supported by the | |
578 | %% program. The Description allows for structured command line usage | |
579 | %% that works in addition to the standard options, and appears between | |
580 | %% the usage_cmd_line and usage_options sections. The CmdLineTail and | |
581 | %% OptionsTail arguments are a string that is added to the end of the | |
582 | %% usage command line and a list of tuples that are added to the end of | |
583 | %% the options' help lines. | |
584 | -spec usage([option_spec()], ProgramName :: string(), CmdLineTail :: string(), | |
585 | Description :: string(), | |
586 | [{OptionName :: string(), Help :: string()}], | |
587 | output_stream()) -> ok. | |
588 | usage(OptSpecList, ProgramName, CmdLineTail, Description, OptionsTail, OutputStream) -> | |
589 | io:format(OutputStream, "~ts~n~n~ts~n~n~ts~n", | |
590 | [unicode:characters_to_list(usage_cmd_line(ProgramName, OptSpecList, CmdLineTail)), Description, unicode:characters_to_list(usage_options(OptSpecList, OptionsTail))]). | |
575 | 591 | |
576 | 592 | |
577 | 593 | -spec usage_cmd_line(ProgramName :: string(), [option_spec()]) -> iolist(). |