cmd
cmd copied to clipboard
User can set a description for their custom command that shows up when executing :ls
The builtin commands have descriptions but custom ones do not.
It would be nice to be able to do something like this:
ssh alpha.cmd.io :create ambiguous "not anymore"
ssh alpha.cmd.io :create ambiguous2 "much less so"
Then the :ls command would show something like:
☰ Commands
ambiguous not anymore
ambiguous2 much less so
Great catch, we had this in before but we lost it while moving things around. I actually think this should be a flag as opposed to positional argument. I tend to avoid flags, but I'm pretty sure :create
is going to require a second arg of -
to indicate using STDIN. In the future, not providing -
may open an editor. But since this is optional and not necessary for basic use, it can be a flag. What do you think?
The Command struct appears to support Description and have null handling <new_to_go/> Not sure how to test this patch locally:
$ git diff app/builtin/create.go
diff --git a/app/builtin/create.go b/app/builtin/create.go
index 52f5780..fc4582a 100644
--- a/app/builtin/create.go
+++ b/app/builtin/create.go
@@ -48,6 +48,7 @@ var createCmd = func(sess cli.Session) *cobra.Command {
Name: args[0],
User: sess.User(),
Source: string(source),
+ Description: args[1],
}
if err := cmd.Build(); err != nil {
No objection to a flag here. I'll need to dig through src more to find out where that would be handled.
Feel free to ask plenty of questions in slack.
Any preference on the name, usage or shorthand for this flag?
--description
, -d
https://github.com/gliderlabs/cmd/tree/joebwan_exp includes a patch worth review. At the moment I'm unable to test locally but make clean && make build
succeed.
https://github.com/gliderlabs/cmd/commit/96de3f8dd5324616f9d4be3fba05b17bce01bccb is tested locally