Comments (8)
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.
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.
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.
@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.
@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.
@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.
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.
from kingpin.
Related Issues (20)
- help don't show all default values HOT 2
- Unexpected "doubling" behavior when trying to test output HOT 1
- gmake: *** [Makefile.common:193: common-unused] Error 1 HOT 1
- Wishlist: release guesswidth as its own separate package HOT 3
- postitive integers HOT 1
- get list of values in flag HOT 1
- Readme uses `OverrideDefaultFromEnvar` which is deprecated
- Documentation of public methods on private structs is hidden HOT 2
- HintAction can break the argument order HOT 1
- "Argument list too long " The flag length limit? HOT 1
- There is a problem with flag and kingpin colleagues
- Bad boolean Flag value is interpreted as Argument HOT 1
- (Contributions only) updated
- Expand DurationVar to support days and weeks
- [bug]bool parameter, the default is true, always true,Cannot be controlled by parameters HOT 1
- Create a new tag please? HOT 4
- Regression in parsing Duration flag HOT 5
- values.go:142:25: undefined: str2duration.Str2Duration HOT 6
- Dependency Dashboard
- Enums() type doesn't tab complete
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kingpin.