Skip to content

Conversation

@v-gb
Copy link
Contributor

@v-gb v-gb commented Oct 24, 2025

Currently, Cmdliner is given a formatter that drops any text, but Cmdliner can (and does) print whitespace via the non-overridden out_spaces, out_indent and out_newlines.

Currently, Cmdliner is given a formatter that drops any text, but Cmdliner can (and
does) print whitespace via the non-overridden out_spaces, out_indent and out_newlines.
lazy
(Cmd.eval_value ~err:discard_formatter ~help:discard_formatter
(Cmd.v info global_lib_term) )
(let discard = Format.formatter_of_buffer (Buffer.create 0) in
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that we no longer have to maintain the formatter_out_functions definition that seems unstable.
Do you think we could use Format.make_formatter to also avoid writing to a buffer ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I looked for a function like this, but didn't see it.

We could use it, but I slightly prefer the buffer as it's just obviously correct (with the other version, you need to consult the documentation). And the formatter and the buffer are going to get gc'ed shortly after the lazy is forced (unless cmdliner is doing weird things).

I think what would make more sense is to stop suppressing errors, and move the command line parsing upfront, but maybe there's a reason why things are the way they are.

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.

2 participants