feat: harden curl_parser, tolerate flags, improve output, and expand tests

- Pre-filter unknown flags before ArgParser; keep positional args.
- Tolerate non-request flags: -v/--verbose, --connect-timeout, --retry, --output, --compressed, -i/--include, --globoff.
- Auth: support --oauth2-bearer; map to - Authorization only if absent.
- Cookies: parse -b/--cookie; accept -c/--cookie-jar (ignored for request).
- URL: prefer first http(s) positional when --url missing; quote cleaning.
- Data: merge data-urlencode → data-raw → data-binary → data; default POST when body/form present; HEAD remains HEAD.
- Forms: parse -F entries; auto-set multipart Content-Type if missing.
- Headers: robust -H parsing for multi-colon values.
- toCurlString: deterministic order; fix continuation spacing; emit -d right after headers/form; place -k/-L at end.
- Utils: normalize backslash-newlines/CRLF; remove stray '+'; shlex split.
- Tests: add unknown flags, oauth2-bearer (and non-override), cookie-jar, verbose/timeout/retry/output tolerance, data merging order, HEAD+data, -A user-agent, -b filename.
- Docs: add Dartdoc for utils; class docs present.
This commit is contained in:
Udhay-Adithya
2025-09-17 00:11:20 +05:30
parent 38cb5eb2d6
commit 8036d60615
5 changed files with 435 additions and 89 deletions

View File

@@ -88,4 +88,17 @@ void main() {
],
);
}, timeout: defaultTimeout);
test('split handles CRLF and backslash-newline', () async {
final args = splitAsCommandLineArgs(
"--request GET \\\r\n --url 'https://api.apidash.dev/echo' \\\n+ \n --header 'A: 1' ");
expect(args, [
'--request',
'GET',
'--url',
'https://api.apidash.dev/echo',
'--header',
'A: 1'
]);
}, timeout: defaultTimeout);
}