cli: trim basic help, drop invented flag, parallelize by default

Surface area, not the machinery, was the problem: 16 flags crowded the
bare --help. Re-tag so basic shows only the 10 outcome-changing flags;
every other flag still works behind --help=<group>.

- cut --bt-metadata-timeout, an invented flag with no real counterpart. Keep
  its 60s magnet-metadata stall as a fixed internal default (bt.go), not a
  user knob.
- fix the parallelism footgun: a bare `got URL` used min(split,x)=1
  connection. When -x is unset, let --split drive per-host connections
  (capped at 16), so `got URL` gets 5 and `-s16` gets 16. An explicit -x
  is honored verbatim, including -x1. Locked by TestHTTPConnDefault.
- -s is the per-download speed dial now, so it moves to basic; -x (a
  per-server cap) moves to the http group. -j help says "files at once,
  not connections within one file".
This commit is contained in:
2026-06-21 15:10:57 +09:00
parent 2d99c39604
commit 3eb2d5ffcb
6 changed files with 82 additions and 55 deletions

View File

@@ -144,6 +144,36 @@ func TestGatherURIsGrouping(t *testing.T) {
}
}
// TestHTTPConnDefault locks the parallelism default: a bare `got URL` must use
// several connections, not one. With -x unset, --split drives the per-host
// connection count (capped at the -x ceiling of 16); an explicit -x is honored
// verbatim, including the aria2-faithful -x1 single connection.
func TestHTTPConnDefault(t *testing.T) {
cfg := func(args ...string) httpdl.Config {
res, err := cli.Parse(append([]string{"--no-conf"}, args...))
if err != nil {
t.Fatalf("parse %v: %v", args, err)
}
return httpConfig(res.Options, true, nil)
}
tests := []struct {
name string
args []string
want int
}{
{"bare URL uses split default", []string{"http://a/x"}, 5},
{"-s16 means 16", []string{"-s16", "http://a/x"}, 16},
{"-s100 capped at 16 per host", []string{"-s100", "http://a/x"}, 16},
{"explicit -x4 honored", []string{"-x4", "http://a/x"}, 4},
{"explicit -x1 stays single", []string{"-x1", "http://a/x"}, 1},
}
for _, tc := range tests {
if c := cfg(tc.args...); c.MaxConnPerServer != tc.want {
t.Errorf("%s: MaxConnPerServer = %d, want %d", tc.name, c.MaxConnPerServer, tc.want)
}
}
}
// TestReadInputFileTAB checks the input-file grouping: TAB-separated URIs on
// a line are mirrors of one download; a plain line is one download.
func TestReadInputFileTAB(t *testing.T) {