Giter Site home page Giter Site logo

How to change help text? about kingpin HOT 8 CLOSED

alecthomas avatar alecthomas commented on July 17, 2024
How to change help text?

from kingpin.

Comments (8)

alecthomas avatar alecthomas commented on July 17, 2024

Hi,

Alas, there is no way to do what you want with the --help flag, and I doubt I will add it unless there's a compelling reason. The help flag is actually heavily special cased so that it works in basically all situations, meaning it is effectively a builtin. It's like this because in Kingpin v1 it was basically just a normal flag, but in certain situations (like invalid flags prior to the help flag) it became impossible to show the help correctly. By special casing it, it always works and always shows you help with as much information as you can.

As for --help-long I'm going to attempt to make that optional, as it is only useful if you have subcommands.

Alec

from kingpin.

cwaltken-edrans avatar cwaltken-edrans commented on July 17, 2024

Hi @alecthomas, I just ran into the same thing.
You can easily a shorthand to the help flag, but you don't allow for a change of the help flags text? I think the default appeals more to a developer using kingpin then an end user. Why would i show them the flag to generate a man-page or a long-help if there is no difference?

app.HelpFlag.Help("My custom text").Short('h')

would be awesome in my opinion...

from kingpin.

alecthomas avatar alecthomas commented on July 17, 2024

I'm not sure what you're referring to... do you mean you'd like to see some longer text for flags, in addition to the flag help? eg. kingpin.Flag("flag", "My flag help.").Help("My longer description of the flag")?

from kingpin.

tssajo avatar tssajo commented on July 17, 2024

@alecthomas He "would like to see" what I wanted to be able to do two years ago:
We would like to be able to get rid of the awful help description which currently looks like this:
--help Show context-sensitive help (also try --help-long and --help-man).
Especially, since we DO NOT HAVE any subcommands in our little apps!
We do not want to show this part to our users at all: "also try --help-long and --help-man", because we do not want that advanced crap. ;)
I considered forking your project just to be able to do this. But what's the point? Probably the best thing is abandoning the package because it is too large with too many unneeded features anyway. It makes a Go command line program megabytes bigger. IMO, it's better to avoid it completely.

from kingpin.

alecthomas avatar alecthomas commented on July 17, 2024

@tssajo It may be that your first language is not English, but you're coming off as entitled and rude. Please feel free to not use Kingpin if it doesn't meet your needs.

@cwaltken-edrans This is fixed in v3-unstable. The help text for --help is now Show context-sensitive help..

from kingpin.

cwaltken-edrans avatar cwaltken-edrans commented on July 17, 2024

@alecthomas what i meant is that it would be nice to be able to customize the text for the help flag freely. I think it's a little rigid to not allow for the user of your library to change that text to their needs.

I ended up doing this ugly hack:

diff --git a/vendor/gopkg.in/alecthomas/kingpin.v2/app.go b/vendor/gopkg.in/alecthomas/kingpin.v2/app.go
index 91083aa..c95ee27 100644
--- a/vendor/gopkg.in/alecthomas/kingpin.v2/app.go
+++ b/vendor/gopkg.in/alecthomas/kingpin.v2/app.go
@@ -59,7 +59,7 @@ func New(name, help string) *Application {
        a.flagGroup = newFlagGroup()
        a.argGroup = newArgGroup()
        a.cmdGroup = newCmdGroup(a)
-       a.HelpFlag = a.Flag("help", "Show context-sensitive help (also try --help-long and --help-man).")
+       a.HelpFlag = a.Flag("help", "Display usage information (this message)")
        a.HelpFlag.Bool()
        a.Flag("help-long", "Generate long help.").Hidden().PreAction(a.generateLongHelp).Bool()
        a.Flag("help-man", "Generate a man page.").Hidden().PreAction(a.generateManPage).Bool()

from kingpin.

hsson avatar hsson commented on July 17, 2024

I found that a simple way to get rid of the annoying help text showing --help-long and --help-man without changing any package code, is to simply do:

func main() {
    app.HelpFlag.Hidden()
    ...

in the start of your own main function, where app in this case is your application created from kingpin.New(). This hides the --help flag in the help output, but this is not a big issue, as the help command is still shown to guide users.

from kingpin.

cwaltken-edrans avatar cwaltken-edrans commented on July 17, 2024

from kingpin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.