this post was submitted on 08 Jul 2023
7 points (100.0% liked)

Rust Lang

3 readers
1 users here now

Rules [Developing]

Observe our code of conduct

Constructive criticism only

No endless relitigation

No low-effort content

No memes or image macros

No NSFW Content

founded 1 year ago
MODERATORS
 

What do you think about this kind of indication for conflicting or otherwise invalid arguments?

With command line arguments being 1D and line length valid up to hundreds of kilobytes only inline indication seems to work.

Would you change anything?

top 4 comments
sorted by: hot top controversial new old
[–] Aloso@lemmyrs.org 4 points 1 year ago (1 children)

You need to tell the user that this is an error, otherwise they don't know if it succeeded or not.

error: --att cannot be used at the same time as --intel

The last line is incomprehensible, just use a full sentence.

[–] manpacket@lemmyrs.org 2 points 1 year ago (1 children)

You need to tell the user that this is an error, otherwise they don’t know if it succeeded or not.

So add "Error:" at the beginning? Looks a bit better, right.

Last line is more or less copy of the command line user gave with markers indicating bits parser does not like.

[–] ActuallyRuben@actuallyruben.nl 4 points 1 year ago (1 children)

I'd recommend adding the markers on a line below the text, in a similar way to how rust compiler output indicates errors.

Also WIN isn't really clear to me what it's supposed to mean, does it mean that flag "wins" and takes precedence over the other conflicting flag? Does that even matter if the program exits with an error anyway?

[–] manpacket@lemmyrs.org 1 points 1 year ago

I’d recommend adding the markers on a line below the text, in a similar way to how rust compiler output indicates errors.

It is easier for the rust compiler to do so since rust files are always valid utf8 and formatted to be of reasonable size. Doing the right thing with OsString is harder, plus lines can be long and trimming it enough that it still fits on a line above all that while also dealing with unicode shenanigans... That's why I'm trying to do things inline where most of those things

Also WIN isn’t really clear to me what it’s supposed to mean, does it mean that flag “wins” and takes precedence over the other conflicting flag?

Right. Wording can use more work :)

Does that even matter if the program exits with an error anyway?

Hmm... Interesting question. I guess it is less useful in this case but I can imagine some stranger situations. Plus I'm trying to create more detailed/user friendly error messages - one is text description "FOO is required" and the other one shows place where exactly this "FOO" is required.