1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
package context
import (
"fmt"
"github.com/spf13/cobra"
"github.com/hetznercloud/cli/internal/state"
)
func newActiveCommand(cli *state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "active [FLAGS]",
Short: "Show active context",
Args: cobra.NoArgs,
TraverseChildren: true,
DisableFlagsInUseLine: true,
RunE: cli.Wrap(runActive),
}
return cmd
}
func runActive(cli *state.State, cmd *cobra.Command, args []string) error {
if cli.Config.ActiveContext != nil {
fmt.Println(cli.Config.ActiveContext.Name)
}
return nil
}
|