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
feat: Add ArgumentSafety and Url::*_as_argument() methods
This adds three methods to `Url`:
- `Url::user_as_argument`
- `Url::host_as_argument`
- `Url::path_as_argument`
They return `ArgumentSafety` values that distingiush three cases:
1. There is no wrapped value (`Absent`).
2. The wrapped value is usable and presumably safe (`Usable`).
3. The wrapped value is dangerous and should not be passed as a
command-line argument because it could be interpreted as an
option due to starting with `-`. The value itself may still be
useful and safe to include in error messages.
`user_as_argument` and `host_as_argument` are the most useful ones,
as they serve as alternatives to `user_argument_safe` and
`host_argument_safe` whose return values are unambiguous. The
`user_argument_safe` and `host_argument_safe` methods don't
distinguish between the absence of a username or host, and the
presence of a username or host that is unsafe to pass as an
argument.
`path_as_argument` included for parity, in case it is useful to
write code that handles the three cases similarly. However, there
is no underlying ambiguity in the return value of the corresponding
`path_argument_safe` method, since unlike `user` and `host`, the
`path` is not an option type.
0 commit comments