You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A value option takes the next argument even when it's a switch: "--reason --display" sets the reason to "--display" and silently drops the flag #38
CommandLineParser.TryTakeValue (TrayApp/Cli/CommandLineParser.cs:189-202) takes args[index + 1] as the option's value without checking what it is. TryReadAppOption calls it at lines 171-176. So when the user forgets a value, the next switch on the command line becomes the value instead.
Failure scenario
Both of these were confirmed with a scratch test against CommandLineParser.TryParse:
TryParse(["--reason", "--display"]) succeeds with a single match: -r with the value "--display". For NoSleep, nosleep --reason --display records the reason "--display" and doesn't keep the display awake. There is no error.
TryParse(["--reason", "--status"]) succeeds with ShowStatus == false. So nosleep -r --status starts a keep-awake run instead of printing the status report.
ReadDuration (line 132) has the same shape. There, though, the duration parse turns the swallowed switch into an error, so only free-text value options are affected silently.
Why it matters
Every other command-line mistake exits 2 with usage. This one makes the run quietly do something other than what was typed. A user who passes --status to check what's happening ends up starting the tool.
Suggested fix / acceptance criteria
In TryTakeValue, if the next argument is a standard alias (StandardAliases) or an alias of an application option, fail with "'--reason' needs a value.".
Values that merely start with - but aren't a known switch, such as - or -5, are still accepted.
Tests:
["--reason", "--display"] and ["--reason", "--status"] fail to parse with "needs a value", and RunAsync exits 2.
["--reason", "-"] and ["--reason", "some text"] still parse.
Priority: Medium. A missing value silently swallows the next switch, so for example nosleep -r --status starts a keep-awake run instead of reporting status. Every other command-line mistake exits 2 with usage.
Area / suggested assignment: TrayApp CommandLineParser.TryTakeValue / TryReadAppOption.
Activity
matt-edmondson commentedon Oct 7, 2026
Triage
nosleep -r --statusstarts a keep-awake run instead of reporting status. Every other command-line mistake exits 2 with usage.CommandLineParser.TryTakeValue/TryReadAppOption.-and-5still parse.Generated by Claude Code