MCPcopy
hub / github.com/1Panel-dev/KubePi / main

Function main

thirdparty/gotty/main.go:18–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16)
17
18func main() {
19 app := cli.NewApp()
20 app.Name = "gotty"
21 app.Version = Version
22 os.Setenv("app.Version", app.Version)
23 app.Usage = "Share your terminal as a web application"
24 app.HideHelp = true
25
26 appOptions := &server.Options{}
27 if err := utils.ApplyDefaultValues(appOptions); err != nil {
28 exit(err, 1)
29 }
30 backendOptions := &localcommand.Options{}
31 if err := utils.ApplyDefaultValues(backendOptions); err != nil {
32 exit(err, 1)
33 }
34 redisOptions := &server.RedisOptions{}
35 if err := utils.ApplyDefaultValues(redisOptions); err != nil {
36 exit(err, 1)
37 }
38 cliFlags, flagMappings, err := utils.GenerateFlags(appOptions, backendOptions, redisOptions)
39 if err != nil {
40 exit(err, 3)
41 }
42
43 app.Flags = append(
44 cliFlags,
45 &cli.StringFlag{
46 Name: "config",
47 Value: "~/.gotty",
48 Usage: "Config file path",
49 EnvVars: []string{"GOTTY_CONFIG"},
50 },
51 )
52
53 app.Action = func(c *cli.Context) error {
54 if c.Args().Len() == 0 {
55 msg := "Error: No command given."
56 cli.ShowAppHelp(c)
57 exit(fmt.Errorf(msg), 1)
58 }
59
60 utils.ApplyFlags(cliFlags, flagMappings, c, appOptions, backendOptions, redisOptions)
61
62 appOptions.EnableBasicAuth = c.IsSet("credential")
63 appOptions.EnableTLSClientAuth = c.IsSet("tls-ca-crt")
64
65 err = appOptions.Validate()
66 if err != nil {
67 exit(err, 6)
68 }
69 err = redisOptions.Validate()
70 if err != nil {
71 exit(err, 6)
72 }
73
74 args := c.Args().Slice()
75 factory, err := localcommand.NewFactory(args[0], args[1:], backendOptions)

Callers

nothing calls this directly

Calls 7

ValidateMethod · 0.95
ValidateMethod · 0.95
exitFunction · 0.85
waitSignalsFunction · 0.85
LenMethod · 0.80
NewMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected