{"record":{"id":"903d516d37b666f3","repo":"wavetermdev/waveterm","slug":"no-arguments-wsh-s-requires-a-file-or-url-as-an","errorCode":null,"errorMessage":"no arguments.  wsh %s requires a file or URL as an argument argument","messagePattern":"no arguments\\.  wsh (.+?) requires a file or URL as an argument argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-view.go","lineNumber":50,"sourceCode":"\tRunE:    viewRun,\n\tPreRunE: preRunSetupRpcClient,\n}\n\nfunc init() {\n\tviewCmd.Flags().BoolVarP(&viewMagnified, \"magnified\", \"m\", false, \"open view in magnified mode\")\n\trootCmd.AddCommand(viewCmd)\n\teditCmd.Flags().BoolVarP(&viewMagnified, \"magnified\", \"m\", false, \"open view in magnified mode\")\n\trootCmd.AddCommand(editCmd)\n}\n\nfunc viewRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tcmdName := cmd.Name()\n\tdefer func() {\n\t\tsendActivity(cmdName, rtnErr == nil)\n\t}()\n\tif len(args) == 0 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"no arguments.  wsh %s requires a file or URL as an argument argument\", cmdName)\n\t}\n\tif len(args) > 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments.  wsh %s requires exactly one argument\", cmdName)\n\t}\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\tfileArg := args[0]\n\tconn := RpcContext.Conn\n\tvar wshCmd *wshrpc.CommandCreateBlockData\n\tif strings.HasPrefix(fileArg, \"http://\") || strings.HasPrefix(fileArg, \"https://\") {\n\t\twshCmd = &wshrpc.CommandCreateBlockData{\n\t\t\tTabId: tabId,\n\t\t\tBlockDef: &waveobj.BlockDef{\n\t\t\t\tMeta: map[string]any{\n\t\t\t\t\twaveobj.MetaKey_View: \"web\",","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-view.go#L32-L68","documentation":"The `wsh view` (or `wsh edit`/`wsh open`) command in Wave Terminal creates a new preview block from a file path or URL. The viewRun handler validates its positional args before doing any work; if the user runs the command with zero arguments it prints the command help and returns this error instead of silently doing nothing. The awkward trailing 'argument argument' is just a formatting quirk in the message template.","triggerScenarios":"Running `wsh view` (or edit/open variants routed through viewRun) with no positional argument at all, e.g. `wsh view` or `wsh edit` on the CLI.","commonSituations":"Users forget the file/URL operand; shell scripts or aliases call the command with an empty variable (`wsh view $FILE` where FILE is unset); documentation examples omit the argument.","solutions":["Pass exactly one file path or http(s) URL, e.g. `wsh view ./notes.md` or `wsh view https://example.com`","If the arg comes from a shell variable, check it is non-empty before invoking: `[ -n \"$FILE\" ] && wsh view \"$FILE\"`","Run `wsh view --help` / `wsh help view` to see the expected usage"],"exampleFix":"// before\n$ wsh view\n// error: no arguments...\n\n// after\n$ wsh view ~/notes.md","handlingStrategy":"validation","validationCode":"if [ -z \"$TARGET\" ]; then echo \"usage: wsh view <file-or-url>\" >&2; exit 2; fi\nwsh view \"$TARGET\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass one quoted operand to wsh view","Guard empty shell variables before invoking","Keep paths quoted to avoid word-splitting surprises"],"tags":["cli","argument-validation","wsh"],"backgroundTag":"missing-required-cli-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}