cmd icon indicating copy to clipboard operation
cmd copied to clipboard

User can set a description for their custom command that shows up when executing :ls

Open joebwan opened this issue 7 years ago • 8 comments

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

joebwan avatar May 02 '17 22:05 joebwan

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?

progrium avatar May 02 '17 22:05 progrium

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 {

joebwan avatar May 02 '17 22:05 joebwan

No objection to a flag here. I'll need to dig through src more to find out where that would be handled.

joebwan avatar May 02 '17 22:05 joebwan

Feel free to ask plenty of questions in slack.

progrium avatar May 02 '17 22:05 progrium

Any preference on the name, usage or shorthand for this flag?

joebwan avatar May 03 '17 06:05 joebwan

--description, -d

progrium avatar May 03 '17 14:05 progrium

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.

joebwan avatar May 03 '17 16:05 joebwan

https://github.com/gliderlabs/cmd/commit/96de3f8dd5324616f9d4be3fba05b17bce01bccb is tested locally

joebwan avatar May 10 '17 23:05 joebwan