cli: simplify option model per pike review
- appendList: one home for the List newline-join rule (was duplicated across accumulate and set) - fold the redundant Int64 getter into Int; drop the truthy helper for the shared boolWord vocabulary - add Opt.Metavar so help derives the value placeholder from data instead of branching on the option name (seed-time) No behavior change; --help output is byte-identical.
This commit is contained in:
@@ -50,6 +50,10 @@ type Opt struct {
|
||||
Kind Kind
|
||||
Default string
|
||||
Help string
|
||||
// Metavar overrides the "=PLACEHOLDER" shown after the flag in --help. Empty
|
||||
// means derive it from Kind (N, SIZE, RATIO, ...). Set it only when the
|
||||
// Kind-derived default would mislead, e.g. seed-time is minutes, not a ratio.
|
||||
Metavar string
|
||||
Tag Tag
|
||||
Enum []string // valid values when Kind == Enum
|
||||
// Min is the inclusive lower Int/Size bound. The zero value enforces a
|
||||
@@ -103,7 +107,7 @@ var options = []Opt{
|
||||
|
||||
// --- bittorrent ---
|
||||
{Long: "torrent-file", Short: 'T', Kind: Str, Help: "path to a .torrent file", Tag: BitTorrent},
|
||||
{Long: "seed-time", Kind: Float, Help: "minutes to seed after completion (0 = no seeding)", Tag: BitTorrent},
|
||||
{Long: "seed-time", Kind: Float, Metavar: "MIN", Help: "minutes to seed after completion (0 = no seeding)", Tag: BitTorrent},
|
||||
{Long: "seed-ratio", Kind: Float, Default: "1.0", Help: "stop seeding at this share ratio (0 = unlimited)", Tag: BitTorrent},
|
||||
{Long: "bt-stop-timeout", Kind: Int, Default: "0", Min: 0, Help: "stop a torrent with no download progress for N seconds (0 = off)", Tag: BitTorrent},
|
||||
{Long: "bt-metadata-timeout", Kind: Int, Default: "60", Min: 0, Help: "stop a magnet that can't fetch metadata in N seconds (0 = off)", Tag: BitTorrent},
|
||||
|
||||
Reference in New Issue
Block a user