iawia002/lux · error
too few arguments
Error message
too few arguments
What it means
Usage error from the lux CLI entrypoint: after flags are parsed and the optional --items/--file input is read, the positional argument list is still empty, so there is no URL to download. The -i file is run through utils.ParseInputFile with --start/--end selecting a line window, and a window that selects no lines yields zero items. It is thrown before any network activity.
Source
Thrown at app/app.go:230
args := c.Args().Slice()
if c.Bool("debug") {
cli.VersionPrinter(c)
}
if file := c.String("file"); file != "" {
f, err := os.Open(file)
if err != nil {
return err
}
defer f.Close() // nolint
fileItems := utils.ParseInputFile(f, c.String("items"), int(c.Uint("start")), int(c.Uint("end")))
args = append(args, fileItems...)
}
if len(args) < 1 {
return errors.New("too few arguments")
}
cookie := c.String("cookie")
if cookie != "" {
// If cookie is a file path, convert it to a string to ensure cookie is always string
if _, fileErr := os.Stat(cookie); fileErr == nil {
// Cookie is a file
data, err := os.ReadFile(cookie)
if err != nil {
return err
}
cookie = strings.TrimSpace(string(data))
}
}
request.SetOptions(request.Options{
RetryTimes: int(c.Uint("retry")),
Cookie: cookie,View on GitHub (pinned to dd00f6d258)
Solutions
- Pass at least one video URL as a positional argument, e.g. lux "https://www.bilibili.com/video/av170001".
- If using -i/--items, confirm the file contains non-empty link lines and that --start/--end fall inside that range.
- When automating, echo the parsed item count before extracting so an empty batch fails loudly at the source.
Example fix
// before $ lux -F mp4 // after $ lux -F mp4 "https://www.bilibili.com/video/av170001" $ lux -F mp4 -i items.txt --start 1 --end 10
Defensive patterns
Strategy: validation
Validate before calling
items := utils.ParseInputFile(f, c.String("items"), int(c.Uint("start")), int(c.Uint("end")))
if len(args)+len(items) == 0 {
return cli.Exit("too few arguments: pass a video URL or a non-empty --items file", 1)
} Try / catch
Not a recoverable runtime error — do not catch. Handle at the CLI layer: print the app usage (cli.ShowAppHelp) and exit non-zero. Retrying with the same argv cannot succeed.
Prevention
- Always include one positional URL, or verify the --items file has non-empty link lines before running
- Validate --start/--end against the line count of the batch file
- In wrappers, check os.Args length before invoking the binary and fail with a clear message
When it happens
Trigger: Invoking the binary with only flags (e.g. lux -F mp4); passing an empty or whitespace-only items file; setting --start/--end outside the number of link lines in the items file so ParseInputFile returns no entries.
Common situations: Scripts or cron jobs that forget the positional URL; batch files with blank lines; 1-based vs 0-based confusion on --start/--end. A bad file path fails earlier at os.Open, but a valid file with no usable lines fails exactly here.
Related errors
AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15).
Data as JSON: /api/errors/bbcbe455256e4871.
Report an issue: GitHub.