Comments (3)
I've been solving this by actually passing the context into the Command
implementations. This removes the nasty interface{}
type unsafety you might get with contexts. example:
struct MyCommand {
Config *MyConfig
}
func (c *MyCommand) Run(args []string) int {
c.Config usage here
}
Thoughts?
from cli.
That's how I ended up solving. Looking through your code for Serf though,
how does Ui get passed into most the command that are initialized with
&command.JoinCommand {}
?
On Tue, Nov 5, 2013 at 1:34 PM, Mitchell Hashimoto <[email protected]
wrote:
I've been solving this by actually passing the context into the Commandimplementations. This removes the nasty
interface{] type unsafety you might get with contexts. example:struct MyCommand {
Config *MyConfig}
func (c *MyCommand) Run(args []string) int {
c.Config usage here}Thoughts?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-27799426
.
from cli.
Ah, I think you saw the old Serf code. I extracted this cli lib from Packer and Serf but had to rework it a bit to be more general. That was one of the changes. Take a look at Serf now. :)
from cli.
Related Issues (20)
- Root command
- Replace current completion generation package with something else HOT 1
- Sporadic test failures in "TestCLIRun_printCommandHelpSubcommands" HOT 5
- please tag and version this project HOT 9
- Top level help shows all subcommand children HOT 2
- Compatibility with standard library `flag` package HOT 3
- Generate help text from command options HOT 2
- Nested Subcommand Help HOT 3
- Flag named version causes application version to be printed incorrectly HOT 1
- Mark commands (and flags) as hidden HOT 5
- panic if a subcommand is wrapped in double quotes and contains spaces HOT 2
- is there support for interactive mode? HOT 3
- default subcommand throws stack overflow HOT 2
- 1.0.0: FAIL: TestCLIAutocomplete_subcommandArgs/RE HOT 1
- Versus cobra cli HOT 1
- How to write shell completion function in Go
- Subcommand parsing logic stops at first flag HOT 3
- Subcommand parsing: "fooasdf -o=foo" is incorrectly identified as the subcommand "foo"
- Update github.com/Masterminds/sprig HOT 1
- Add flags dynamically HOT 1
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 cli.