github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/cmd/pyroscope/command/agent.go (about)

     1  package command
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  
     6  	"github.com/pyroscope-io/pyroscope/pkg/cli"
     7  	"github.com/pyroscope-io/pyroscope/pkg/config"
     8  )
     9  
    10  func newAgentCmd(cfg *config.Agent) *cobra.Command {
    11  	vpr := newViper()
    12  	agentCmd := &cobra.Command{
    13  		Use:   "agent [flags]",
    14  		Short: "Start pyroscope agent",
    15  
    16  		DisableFlagParsing: true,
    17  		RunE: cli.CreateCmdRunFn(cfg, vpr, func(_ *cobra.Command, _ []string) error {
    18  			return cli.StartAgent(cfg)
    19  		}),
    20  	}
    21  
    22  	cli.PopulateFlagSet(cfg, agentCmd.Flags(), vpr, cli.WithSkip("targets"))
    23  	return agentCmd
    24  }