Skip to content

Commit

Permalink
feat(exec): add help text and example usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mroth committed Dec 5, 2021
1 parent 93dc4a4 commit a5994d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions commands/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var expandRelative bool

// CommandExec expands numeric arguments then execs the command
// CommandExec expands numeric arguments then executes the command directly.
//
// Allows expansion of numbered shortcuts, ranges of shortcuts, or standard paths.
// Numbered shortcut variables are produced by various commands, such as:
Expand All @@ -20,8 +20,10 @@ var expandRelative bool
func CommandExec() *cobra.Command {

var expandCmd = &cobra.Command{
Use: "exec <shortcuts...>",
Short: "Execute cmd with numeric shortcuts",
Use: "exec [flags] <command> <shortcuts...>",
Example: "$ scmpuff exec git add 1-4",
Aliases: []string{"execute"},
Short: "Execute cmd with numeric shortcuts",
Long: `Expands numeric shortcuts to their full filepath and executes the command.
Takes a list of digits (1 4 5) or numeric ranges (1-5) or even both.`,
Expand Down Expand Up @@ -72,4 +74,3 @@ func Process(args []string) []string {

return processedArgs
}

4 changes: 2 additions & 2 deletions commands/expand/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ var expandRelative bool
func CommandExpand() *cobra.Command {

var expandCmd = &cobra.Command{
Use: "expand <shortcuts...>",
Use: "expand [flags] <shortcuts...>",
Short: "Expands numeric shortcuts",
Long: `Expands numeric shortcuts to their full filepath.
Takes a list of digits (1 4 5) or numeric ranges (1-5) or even both.`,
Example: "$ scmpuff expand 1-2\n/tmp/foo.txt /tmp/bar.txt",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
cmd.Usage()
Expand Down Expand Up @@ -73,4 +74,3 @@ func Process(args []string) string {
func escape(arg string) string {
return shellEscaper.ReplaceAllString(arg, "\\$1")
}

0 comments on commit a5994d7

Please sign in to comment.