Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Generate help text from command options #51

Closed
tleyden opened this issue Feb 1, 2017 · 2 comments
Closed

Generate help text from command options #51

tleyden opened this issue Feb 1, 2017 · 2 comments

Comments

@tleyden
Copy link

tleyden commented Feb 1, 2017

I have the following help text:

func (c *cloudformationStopInstancesCommand) Help() string {

	helpText := `
Usage: cloudformation stop-instances [options]
  Stops all instances in the given cloudformation stack
Options:
  -stackname=stackname      The name of the cloudformation stack
  -region=region            The AWS region
 `
	return strings.TrimSpace(helpText)

}

but I was wondering if it possible to generate the Options section from the options usage params?

stackname := cmdFlags.String("stackname", "", "The name of the cloudformation stack")
region := cmdFlags.String("region", "", "The AWS region")

Right now I am duplicating the usage strings. I feel like I'm doing something wrong here..

@mitchellh
Copy link
Owner

You can, but I don't think its this packages job to do so. I purposely designed the "cli" package to not care about command line parsing, which I viewed as a separate and complex task in its own right. That is why this package only deals with []string and doesn't do any CLI parsing, allowing you to use flag or any 3rd party flag parsing.

If another tool lets you turn your options into help text, I'd recommend you use that on top of CLI, rather than it being built in here.

@tleyden
Copy link
Author

tleyden commented Feb 1, 2017

Thanks, makes sense!

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

No branches or pull requests

2 participants