mirror of
https://github.com/holos-run/holos.git
synced 2026-03-19 08:44:58 +00:00
And add a logout command that deletes the token cache. The token package is intended for subcommands that need to make API calls to the holos api server, getting a token should be a simple matter of calling the token.Get() method, which takes minimal dependencies.
32 lines
726 B
Go
32 lines
726 B
Go
package command
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/holos-run/holos/pkg/errors"
|
|
"github.com/holos-run/holos/pkg/version"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// RunFunc is a cobra.Command RunE function.
|
|
type RunFunc func(c *cobra.Command, args []string) error
|
|
|
|
// New returns a new subcommand
|
|
func New(name string) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: name,
|
|
Version: version.Version,
|
|
Args: cobra.NoArgs,
|
|
CompletionOptions: cobra.CompletionOptions{
|
|
HiddenDefaultCmd: true,
|
|
},
|
|
RunE: func(c *cobra.Command, args []string) error {
|
|
return errors.Wrap(fmt.Errorf("could not run %v: not implemented", c.Name()))
|
|
},
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
}
|
|
cmd.Flags().SortFlags = false
|
|
return cmd
|
|
}
|