[util] Allow setting cli summary / description

This commit is contained in:
Behdad Esfahbod 2021-08-12 11:17:26 -06:00
parent 4f3b7b7035
commit c45d2a9c9d
5 changed files with 16 additions and 2 deletions

View File

@ -37,6 +37,7 @@ struct shape_closure_consumer_t
{
void add_options (struct option_parser_t *parser)
{
parser->set_summary ("Find glyph set from input text under shaping closure.");
shaper.add_options (parser);
GOptionEntry entries[] =

View File

@ -40,6 +40,7 @@ struct output_buffer_t : output_options_t<>
{
void add_options (option_parser_t *parser)
{
parser->set_summary ("Shape text with given font.");
output_options_t::add_options (parser, hb_buffer_serialize_list_formats ());
format.add_options (parser);
}

View File

@ -586,6 +586,8 @@ subset_main_t::collect_rest (const char *name,
void
subset_main_t::add_options ()
{
set_summary ("Subset fonts to specification.");
face_options_t::add_options (this);
GOptionEntry glyphset_entries[] =

View File

@ -72,8 +72,8 @@ fail (hb_bool_t suggest_help, const char *format, ...)
struct option_parser_t
{
option_parser_t (const char *usage = nullptr)
: context (g_option_context_new (usage)),
option_parser_t (const char *parameter_string = nullptr)
: context (g_option_context_new (parameter_string)),
to_free (g_ptr_array_new ())
{}
@ -130,6 +130,15 @@ struct option_parser_t
g_option_context_set_main_group (context, group);
}
void set_summary (const char *summary)
{
g_option_context_set_summary (context, summary);
}
void set_description (const char *description)
{
g_option_context_set_description (context, description);
}
void free_later (char *p) {
g_ptr_array_add (to_free, p);
}

View File

@ -40,6 +40,7 @@ struct view_cairo_t : view_options_t, output_options_t<>
void add_options (option_parser_t *parser)
{
parser->set_summary ("View text with given font.");
view_options_t::add_options (parser);
output_options_t::add_options (parser, helper_cairo_supported_formats);
}