Skip to content

Commit bd21b45

Browse files
committed
🐛 FIX: commands reject unknown options
Organ Pulse's agent read the current AGENTS.md, ran render --tracks on a binary built before it, and got the whole song with no error; --bogus passed too. Each command now lists the options it takes and fails on anything else.
1 parent 49b53e6 commit bd21b45

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ All notable changes to Wavelength. Versions follow semantic versioning.
8282
wrecks the track's loudness reading: those samples are muted and the track warns with the time.
8383

8484
### Changed
85+
- Every command rejects options it doesn't know, naming the ones it takes. They used to be
86+
ignored: an agent with newer docs than its binary ran `render --tracks` and silently got the
87+
whole song.
8588
- The limiter's warning adds its gain reduction per marker section (average and maximum), so the
8689
drops' limiting shows next to the quiet sections'.
8790
- A master `loudness` target now adds its gain in front of the chain's last built-in `limiter`

‎src/main.cpp‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,28 @@ int run(int argc, char **argv) {
835835
std::fflush(OUT);
836836
platform::quickExit(0); // skip plugin static destructors, which some plugins crash in
837837
}
838+
{ // an option a command doesn't know is an error: a typo (or a newer flag on an older binary) must not be ignored
839+
static const std::map<std::string, std::set<std::string>> known = {
840+
{"plugins", {"--rescan", "--json", "--block", "--unblock", "--reason"}},
841+
{"params", {"--preset", "--state", "--format", "--all", "--json", "--verbose"}},
842+
{"presets", {"--search", "--rescan", "--json"}},
843+
{"samples", {"--search", "--kit", "--roundrobin", "--json"}},
844+
{"analyze", {"--start", "--end", "--song-time", "--grid", "--div", "--json"}},
845+
{"audition", {"--jobs", "--limit", "--rebuild", "--retag", "--json", "--verbose"}},
846+
{"render", {"--out", "--stems", "--jobs", "--tracks", "--json", "--verbose"}},
847+
{"master", {"--chain", "--loudness", "--lead-in", "--input-lead-in", "--out", "--json", "--verbose"}},
848+
{"state", {"--out", "--preset", "--state", "--format", "--json", "--verbose"}},
849+
{"lint", {"--tracks", "--low", "--crossings", "--json"}},
850+
{"version", {"--json"}}};
851+
auto it = known.find(cmd);
852+
if (it != known.end())
853+
for (auto &[k, v] : a.opts)
854+
if (!it->second.count(k)) {
855+
std::string list;
856+
for (auto &o : it->second) list += (list.empty() ? "" : " ") + o;
857+
return fail(a, "unknown option " + k + " for `" + cmd + "` (it takes: " + list + (cmd == "state" ? " --set" : "") + ")");
858+
}
859+
}
838860
try {
839861
if (cmd == "plugins") return cmdPlugins(a);
840862
if (cmd == "params") return cmdParams(a);

0 commit comments

Comments
 (0)