safing-portmaster/cmds/portmaster-start/show.go
2020-07-22 15:11:34 +02:00

41 lines
864 B
Go

package main
import (
"fmt"
"strings"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(showCmd)
// sub-commands of show are registered using registerComponent
}
var showCmd = &cobra.Command{
Use: "show",
PersistentPreRunE: func(*cobra.Command, []string) error {
// all show sub-commands need the data-root but no logging.
return configureDataRoot()
},
Short: "Show the command to run a Portmaster component yourself",
}
func show(cmd *cobra.Command, opts *Options, cmdArgs []string) error {
// get original arguments
args := getExecArgs(opts, cmdArgs)
// adapt identifier
if onWindows {
opts.Identifier += ".exe"
}
file, err := registry.GetFile(platform(opts.Identifier))
if err != nil {
return fmt.Errorf("could not get component: %s", err)
}
fmt.Printf("%s %s\n", file.Path(), strings.Join(args, " "))
return nil
}