Help us shape the future of Go! Take the 2026 Go Developer Survey

commands

package
v1.3.103 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package commands cmd/dmsg/pty-cli/commands/root.go c1-net-dmsg

Package commands cmd/dmsg/pty-cli/commands/whitelist.go c1-net-dmsg

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   dmsgcli.ExecName(),
	Short: "DMSG pseudoterminal command line interface",
	Long: calvin.AsciiFont("dmsgpty-cli") + `
	DMSG pseudoterminal command line interface`,
	SilenceErrors:         true,
	SilenceUsage:          true,
	DisableSuggestions:    true,
	DisableFlagsInUseLine: true,
	PreRun: func(*cobra.Command, []string) {

		if _, err := os.Stat(confPath); err != nil {
			cli.Log.Fatalf("Config file %s not found.", confPath)
		}

		file, err := os.ReadFile(confPath)
		if err != nil {
			cli.Log.Fatalln("Unable to read ", confPath, err)
		}

		err = json.Unmarshal(file, &conf)
		if err != nil {
			cli.Log.Errorln(err)

			b, err := json.MarshalIndent(conf, "", "  ")
			if err != nil {
				cli.Log.Fatalln("Unable to marshal conf")
			}

			err = os.WriteFile(confPath, b, 0600)
			if err != nil {
				cli.Log.Fatalln("Unable to write", confPath, err)
			}
		}
		conf.CLIAddr = pty.ParseWindowsEnv(conf.CLIAddr)
		if conf.CLIAddr != "" {
			cli.Addr = conf.CLIAddr
		}
		if conf.CLINet != "" {
			cli.Net = conf.CLINet
		}
		if remoteAddr.Port == 0 {
			remoteAddr.Port = pty.DefaultPort
		}
	},
	RunE: func(_ *cobra.Command, _ []string) error {
		if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil {
			log.Printf("Failed to output build info: %v", err)
		}

		ctx, cancel := cmdutil.SignalContext(context.Background(), nil)
		defer cancel()

		if remoteAddr.PK.Null() {

			return cli.StartLocalPty(ctx, cmdName, cmdArgs...)
		}

		return cli.StartRemotePty(ctx, remoteAddr.PK, remoteAddr.Port, cmdName, cmdArgs...)
	},
}

RootCmd contains commands for dmsgpty-cli; which interacts with the dmsgpty-host instance (i.e. skywire-visor)

Functions

func Execute

func Execute()

Execute executes the root command.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL