args
args copied to clipboard
Support "/" options on Windows, and "/?" for help
<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="96" height="96"hspace="10"> Issue by munificent Originally opened as dart-lang/sdk#19806
Right now, args follows Unix conventions (such as they are) for option syntax. Many Windows applications also do that, but Windows also has its own rough conventions. Some don't play nice with what args already supports, but I think we should allow:
- "/?" as an alias for "--help".
- Long and short options can start with "/" instead of "-" and "--". Combined short options are not supported, so "/foo" is always "--foo" and never "-f -o o".
- ":" as a parameter separator, as in "/output:somefile.txt". This will only be supported when the prefix is "/".
<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent
Marked this as blocking dart-lang/sdk#7489.
<img src="https://avatars.githubusercontent.com/u/103167?v=3" align="left" width="48" height="48"hspace="10"> Comment by srawlins
I think it would be crazy unexpected if on a non-Windows system, args parsed arguments starting with a / as an option. IE:
my_dart_script --foo=bar /baz
If my_dart_script happens to also have an option "--baz" defined, it should not read "/baz" as an option! I suggest using Platform.isWindows for this feature. This is still a little wonky, however, because then Window folks would still be able to supply options with -- and with /, so the above example is just as confusing, but only for Windows folks.
<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent
Yeah, I don't think we should support any of this on non-Windows platforms. Platform.isWindows is probably the right approach, but note that that's a breaking change for args. Currently, it doesn't import anything except "dart:io" and it can be used outside of the standalone VM.
Uri.base
can be used now to determine the operating system without importing dart:io
.