Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the generated manpage, groups whose options are all hidden still have their header printed #273

Closed
chipaca opened this issue Sep 24, 2018 · 2 comments

Comments

@chipaca
Copy link
Contributor

chipaca commented Sep 24, 2018

As promised, here's the bug: given

package main

import "os"
import "github.com/jessevdk/go-flags"

type options struct {
	A bool `short:"a" description:"align graviton beams"`
	G struct {
		W bool `long:"foo" description:"count woodchucks" hidden:"yes"`
	} `group:"Hidden options"`
	Z bool `short:"z" description:"engage reverse thrusters"`
}

func main() { flags.NewParser(&options{}, 0).WriteManPage(os.Stdout) }

you get

$ GOPATH=~/canonical/snappy/ go run /tmp/bug3.go cmd | MANWIDTH=60 man  -l -  | cat
bug3(1)           General Commands Manual          bug3(1)

NAME
       bug3 -

SYNOPSIS
       bug3 [OPTIONS]

DESCRIPTION
OPTIONS
   Application Options
       -a     align graviton beams

       -z     engage reverse thrusters

   Hidden options
                     24 September 2018             bug3(1)
chipaca added a commit to chipaca/go-flags that referenced this issue Sep 24, 2018
Without this change, a non-hidden group with only hidden options will
still appear in the generated manpage. This fixes that.
chipaca added a commit to chipaca/go-flags that referenced this issue Sep 24, 2018
Without this change, a non-hidden group with only hidden options will
still appear in the generated manpage. This fixes that.
@jessevdk
Copy link
Owner

Can you confirm this fixed?

@chipaca
Copy link
Contributor Author

chipaca commented Sep 27, 2018

Yes:

$ cat /tmp/bug3.go 
package main

import "os"
import "github.com/jessevdk/go-flags"

type options struct {
	A bool `short:"a" description:"align graviton beams"`
	G struct {
		W bool `long:"foo" description:"count woodchucks" hidden:"yes"`
	} `group:"Hidden options"`
	Z bool `short:"z" description:"engage reverse thrusters"`
}

func main() { flags.NewParser(&options{}, 0).WriteManPage(os.Stdout) }
$ go run /tmp/bug3.go | man -l - | cat
bug3(1)           General Commands Manual          bug3(1)

NAME
       bug3 -

SYNOPSIS
       bug3 [OPTIONS]

DESCRIPTION
OPTIONS
   Application Options
       -a     align graviton beams

       -z     engage reverse thrusters

                     27 September 2018             bug3(1)

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants