Skip to content

Commit

Permalink
docs(cmd): Add util.CompleteROM
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 14, 2024
1 parent bda8c43 commit 5269100
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions cmd/gones/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"gabe565.com/gones/cmd/options"
"gabe565.com/gones/internal/config"
"gabe565.com/gones/internal/util"
"github.com/spf13/cobra"
)

Expand All @@ -17,10 +18,8 @@ func New(opts ...options.Option) *cobra.Command {
Use: "gones ROM",
Short: "NES emulator written in Go",
RunE: runCobra,
ValidArgsFunction: func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"nes"}, cobra.ShellCompDirectiveFilterFileExt
},

ValidArgsFunction: util.CompleteROM,
SilenceErrors: true,
DisableAutoGenTag: true,
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/nesutil/ls/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ func New() *cobra.Command {
Aliases: []string{"list"},
RunE: run,

ValidArgsFunction: func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"nes"}, cobra.ShellCompDirectiveFilterFileExt
},
ValidArgsFunction: util.CompleteROM,
}

flag := cmd.Flags()
Expand Down
7 changes: 7 additions & 0 deletions internal/util/cobra.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package util

import "github.com/spf13/cobra"

func CompleteROM(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"nes"}, cobra.ShellCompDirectiveFilterFileExt
}

0 comments on commit 5269100

Please sign in to comment.