File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
1010 "github.com/spf13/cobra"
1111)
1212
13- var Version = "2.7.2 "
13+ var Version = "3.0.0 "
1414
1515var successStyle = lipgloss .NewStyle ().
1616 Bold (true ).
@@ -26,10 +26,20 @@ Syntax: rapide [margin-key] | [bullet] content
2626Example: rapide work | - Martin updated git repo` ,
2727 Args : cobra .MinimumNArgs (1 ),
2828 Run : func (cmd * cobra.Command , args []string ) {
29- // Default action is to add an entry
30- if args [0 ] == "list" {
31- // This will be handled by the list subcommand
32- return
29+ // If the first argument is a registered subcommand, let it handle the execution.
30+ // Cobra usually does this automatically, but since we have a greedy Run function
31+ // on the root command, we need to be careful not to consume subcommands.
32+ if len (args ) > 0 {
33+ for _ , sub := range cmd .Commands () {
34+ if sub .Name () == args [0 ] {
35+ // Found a subcommand match, this Run shouldn't have been called
36+ // Or we can manually execute it if needed, but usually we just return
37+ // and let Cobra handle it if Run was NOT defined.
38+ // However, since Run IS defined, it takes precedence.
39+ sub .Run (sub , args [1 :])
40+ return
41+ }
42+ }
3343 }
3444
3545 s , err := storage .NewStorage ()
You can’t perform that action at this time.
0 commit comments