After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 504142 - Do not show empty groups in --help output
Do not show empty groups in --help output
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-12-17 22:31 UTC by Yevgen Muntyan
Modified: 2007-12-24 11:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.97 KB, patch)
2007-12-17 22:32 UTC, Yevgen Muntyan
none Details | Review
[1/1] Do not show empty groups in --help output. Initial patch from Yevgen (10.45 KB, patch)
2007-12-18 16:49 UTC, Mathias Hasselmann (IRC: tbf)
accepted-commit_now Details | Review

Description Yevgen Muntyan 2007-12-17 22:31:18 UTC
g_option_context_get_help() prints all groups in the context, even if a group has only hidden or G_OPTIONA_FLAG_IN_MAIN entries. Attached patch makes --help and --help-all print only groups which have some options displayed with --help-all.
Comment 1 Yevgen Muntyan 2007-12-17 22:32:36 UTC
Created attachment 101149 [details] [review]
patch
Comment 2 Mathias Hasselmann (IRC: tbf) 2007-12-18 16:49:34 UTC
Created attachment 101204 [details] [review]
[1/1] Do not show empty groups in --help output. Initial patch from Yevgen

Muntyan. (#504142)

* glib/goption.c: Do not show empty groups in --help output.
* glib/tests/Makefile.am: Add option-context.c
* glib/tests/option-context.c: Test skipping of empty groups.
---
 ChangeLog                   |    9 +++
 glib/goption.c              |   83 +++++++++++++++++-----
 glib/tests/Makefile.am      |    4 +
 glib/tests/option-context.c |  162 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 241 insertions(+), 17 deletions(-)
Comment 3 Mathias Hasselmann (IRC: tbf) 2007-12-18 16:53:02 UTC
Seems the initial patch didn't catch all cases where empty groups where shown. This patch tries to do better, and also adds an unit-test.

Problems: The behaviour of --help-foo, where "foo" is an empty group is kind of unclear. With that patch no entry for "--help-foo" is generated on "--help", but "--help-foo" still is accepted - without creating any output for "foo". Is that ok? Or should "--help-foo" be rejected? Or should glib print some additional information?
Comment 4 Yevgen Muntyan 2007-12-18 17:10:38 UTC
(In reply to comment #3)

> Problems: The behaviour of --help-foo, where "foo" is an empty group is kind of
> unclear. With that patch no entry for "--help-foo" is generated on "--help",
> but "--help-foo" still is accepted - without creating any output for "foo". Is
> that ok? Or should "--help-foo" be rejected? Or should glib print some
> additional information?

With my patch --help-foo did print non-hidden options I believe, which is good (though the --help-foo option itself becomes hidden, which is good too).
But I did miss the case when all options are hidden. I'd think --help-foo shouldn't be accepted at all if all the options in group "foo" are hidden (with G_OPTION_FLAG_HIDDEN, not just G_OPTION_FLAG_IN_MAIN). And same thing for empty groups.
Comment 5 Matthias Clasen 2007-12-22 18:00:16 UTC
I can hardly get excited about the treatment of empty groups, 
but the patch looks ok to me.
Comment 6 Mathias Hasselmann (IRC: tbf) 2007-12-24 11:13:41 UTC
2007-12-22  Mathias Hasselmann  <mathias@openismus.com>

	Do not show empty groups in --help output. Initial patch from Yevgen
	Muntyan. (#504142)

	* glib/goption.c: Do not show empty groups in --help output.
	* glib/tests/Makefile.am: Add option-context.c
	* glib/tests/option-context.c: Test skipping of empty groups.