github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/cmd/tools/k9s.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // SPDX-FileCopyrightText: 2021-Present The Jackal Authors
     3  
     4  // Package tools contains the CLI commands for Jackal.
     5  package tools
     6  
     7  import (
     8  	"os"
     9  
    10  	"github.com/Racer159/jackal/src/config/lang"
    11  	k9s "github.com/derailed/k9s/cmd"
    12  	"github.com/spf13/cobra"
    13  
    14  	// This allows for go linkname to be used in this file.  Go linkname is used so that we can pull the CLI flags from k9s and generate proper docs for the vendored tool.
    15  	_ "unsafe"
    16  )
    17  
    18  //go:linkname k9sRootCmd github.com/derailed/k9s/cmd.rootCmd
    19  var k9sRootCmd *cobra.Command
    20  
    21  func init() {
    22  	k9sCmd := &cobra.Command{
    23  		Use:     "monitor",
    24  		Aliases: []string{"m", "k9s"},
    25  		Short:   lang.CmdToolsMonitorShort,
    26  		Run: func(_ *cobra.Command, _ []string) {
    27  			// Hack to make k9s think it's all alone
    28  			os.Args = []string{os.Args[0]}
    29  			k9s.Execute()
    30  		},
    31  	}
    32  
    33  	k9sCmd.Flags().AddFlagSet(k9sRootCmd.Flags())
    34  
    35  	toolsCmd.AddCommand(k9sCmd)
    36  }