{"record":{"id":"5235df717ba4aefb","repo":"yudai/gotty","slug":"error-no-command-given","errorCode":null,"errorMessage":"Error: No command given.","messagePattern":"Error: No command given\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":56,"sourceCode":"\tif err != nil {\n\t\texit(err, 3)\n\t}\n\n\tapp.Flags = append(\n\t\tcliFlags,\n\t\tcli.StringFlag{\n\t\t\tName:   \"config\",\n\t\t\tValue:  \"~/.gotty\",\n\t\t\tUsage:  \"Config file path\",\n\t\t\tEnvVar: \"GOTTY_CONFIG\",\n\t\t},\n\t)\n\n\tapp.Action = func(c *cli.Context) {\n\t\tif len(c.Args()) == 0 {\n\t\t\tmsg := \"Error: No command given.\"\n\t\t\tcli.ShowAppHelp(c)\n\t\t\texit(fmt.Errorf(msg), 1)\n\t\t}\n\n\t\tconfigFile := c.String(\"config\")\n\t\t_, err := os.Stat(homedir.Expand(configFile))\n\t\tif configFile != \"~/.gotty\" || !os.IsNotExist(err) {\n\t\t\tif err := utils.ApplyConfigFile(configFile, appOptions, backendOptions); err != nil {\n\t\t\t\texit(err, 2)\n\t\t\t}\n\t\t}\n\n\t\tutils.ApplyFlags(cliFlags, flagMappings, c, appOptions, backendOptions)\n\n\t\tappOptions.EnableBasicAuth = c.IsSet(\"credential\")\n\t\tappOptions.EnableTLSClientAuth = c.IsSet(\"tls-ca-crt\")\n\n\t\terr = appOptions.Validate()\n\t\tif err != nil {\n\t\t\texit(err, 6)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/yudai/gotty/blob/a080c85cbc59226c94c6941ad8c395232d72d517/main.go#L38-L74","documentation":"The CLI app's default Action requires at least one positional argument: the command to run inside the PTY (e.g. bash). If no args are given, it prints the help text and exits with status 1 and this message. GoTTY has no default command, so one must always be supplied.","triggerScenarios":"Running `gotty` (or `gotty --port 8080`) with no command argument after options.","commonSituations":"Putting options after the intended command or forgetting the command entirely; scripts invoking gotty with an empty command variable.","solutions":["Pass a command as the final positional argument: gotty -w bash","If the command is built from a variable, verify it is non-empty before invoking","Reorder flags so they precede the command argument"],"exampleFix":"// before\ngotty --port 8080\n// after\ngotty --port 8080 bash","handlingStrategy":"validation","validationCode":"if [ -z \"$GOTTY_CMD\" ]; then echo \"usage: gotty [options] <command>\" >&2; exit 1; fi\ngotty --port 8080 \"$GOTTY_CMD\"","typeGuard":null,"tryCatchPattern":"gotty --port 8080 bash || exit $?  # nonzero exit with 'Error: No command given.' if arg missing","preventionTips":["Always end the gotty invocation with a command argument","Quote shell variables so an empty var doesn't drop the arg","Place flags before the command"],"tags":["cli","usage","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"a080c85cbc59226c94c6941ad8c395232d72d517","analyzedAt":"2026-09-02T16:42:38.150Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}