mirror of
https://github.com/jimeh/evm.git
synced 2026-02-19 07:26:40 +00:00
refactor: extract core logic to a plain Go package
This commit is contained in:
39
commands/commands.go
Normal file
39
commands/commands.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package commands
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
type runEFunc func(cmd *cobra.Command, _ []string) error
|
||||
|
||||
type validArgsFunc func(
|
||||
cmd *cobra.Command,
|
||||
args []string,
|
||||
toComplete string,
|
||||
) ([]string, cobra.ShellCompDirective)
|
||||
|
||||
func noValidArgs(
|
||||
_ *cobra.Command,
|
||||
_ []string,
|
||||
_ string,
|
||||
) ([]string, cobra.ShellCompDirective) {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func flagString(cmd *cobra.Command, name string) string {
|
||||
var r string
|
||||
|
||||
if f := cmd.Flag(name); f != nil {
|
||||
r = f.Value.String()
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func stringsContains(haystack []string, needle string) bool {
|
||||
for _, s := range haystack {
|
||||
if s == needle {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user