wavetermdev/waveterm · error
too many arguments. wsh %s requires exactly one argument
Error message
too many arguments. wsh %s requires exactly one argument
What it means
The wsh view command accepts exactly one positional argument: a single file path or URL. viewRun enforces `len(args) > 1` and rejects the invocation, printing help plus this error, because there is no defined behavior for multiple targets in one command call.
Source
Thrown at cmd/wsh/cmd/wshcmd-view.go:54
func init() {
viewCmd.Flags().BoolVarP(&viewMagnified, "magnified", "m", false, "open view in magnified mode")
rootCmd.AddCommand(viewCmd)
editCmd.Flags().BoolVarP(&viewMagnified, "magnified", "m", false, "open view in magnified mode")
rootCmd.AddCommand(editCmd)
}
func viewRun(cmd *cobra.Command, args []string) (rtnErr error) {
cmdName := cmd.Name()
defer func() {
sendActivity(cmdName, rtnErr == nil)
}()
if len(args) == 0 {
OutputHelpMessage(cmd)
return fmt.Errorf("no arguments. wsh %s requires a file or URL as an argument argument", cmdName)
}
if len(args) > 1 {
OutputHelpMessage(cmd)
return fmt.Errorf("too many arguments. wsh %s requires exactly one argument", cmdName)
}
tabId := getTabIdFromEnv()
if tabId == "" {
return fmt.Errorf("no WAVETERM_TABID env var set")
}
fileArg := args[0]
conn := RpcContext.Conn
var wshCmd *wshrpc.CommandCreateBlockData
if strings.HasPrefix(fileArg, "http://") || strings.HasPrefix(fileArg, "https://") {
wshCmd = &wshrpc.CommandCreateBlockData{
TabId: tabId,
BlockDef: &waveobj.BlockDef{
Meta: map[string]any{
waveobj.MetaKey_View: "web",
waveobj.MetaKey_Url: fileArg,
},
},
Magnified: viewMagnified,View on GitHub (pinned to a4447c1563)
Solutions
- Pass exactly one target; quote paths containing spaces: `wsh view "my file.txt"`
- Open multiple files with separate invocations: `wsh view a.md && wsh view b.md`
- Check `echo $#` or your wrapper's arg count before delegating to wsh
Example fix
// before $ wsh view my file.txt // two args -> error // after $ wsh view "my file.txt"
Defensive patterns
Strategy: validation
Validate before calling
set -- "$@" if [ "$#" -ne 1 ]; then echo "wsh view takes exactly one argument" >&2; exit 2; fi wsh view "$1"
Prevention
- Quote paths containing spaces
- Open multiple targets with separate invocations
- Count args in wrapper scripts before delegating
When it happens
Trigger: Running `wsh view file1 file2` or any invocation with two or more positional arguments, e.g. unquoted paths with spaces (`wsh view my file.txt` expands to two args) or leftover extra args in a script.
Common situations: Unquoted paths containing spaces in shell scripts; users trying to open several files at once; accidental extra flags parsed as positional args after `--`.
Related errors
- stdin (-) can only be used once
- no arguments. wsh %s requires a file or URL as an argument
- no arguments. wsh wavepath requires a type argument (config,
- too many arguments. wsh wavepath requires exactly one argume
- invalid path type %q. must be one of: config, data, log
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/73a8355afdea261a.
Report an issue: GitHub.