Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for quoted arguments containing spaces #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DrewTChrist
Copy link

Hello,

I'd like to add support for quoted arguments that contain spaces. Please feel free to suggest improvements, it's not exactly a pretty change. Rebuilding the arguments character by character from [u8; 32] is maybe a limiting approach. Anyways suggestions are welcome.

The current result of the main branch is this:
current

The result under the changes of this pull request is this:
quoted

@eldruin
Copy link
Member

eldruin commented Apr 24, 2023

Opinions on this @thejpster?

@thejpster
Copy link
Member

I haven't opened the diff yet but the reason I didn't do this is so I could always sub slice the input buffer. If you have to trim escaping backslashes then you can't. Or rather, you have to mutate the input buffer to trim the escapes.

So, not impossible, but it required extra work.

Ok, let me go look!

argument_count += 1;
if arg.starts_with("--") {
// buffer of characters and lengths
let mut buf = [([0u8; 32], 0_usize); 16];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 x 16 bytes is quite a big increase of memory usage compared to what we had before.

If this remains it should be a const generic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or it might be better to de-escape the buffer in place. Any de-escaped string must be the same length or shorter than the input string, and so that should always fit into the buffer that's available.

@thejpster
Copy link
Member

Another option could be a Raw parameter type, which just gives everything to the handler as one long string. The handler can then do its own parsing and de-escaping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants