dwarfs icon indicating copy to clipboard operation
dwarfs copied to clipboard

Allow repeating/overriding options when creating images

Open Phantop opened this issue 2 years ago • 2 comments

This issue is specifically with the lookback option -B, however it is possible it applies to other user-supplied options. I just have not tried with anything else.

Essentially, my appdwarf project sets a default lookback level higher than the builtin default for mkdwarfs. However, I want to keep the option to change that setting.

If I handled this lazily, a possible commandline would look something like mkdwarfs -B5 -i in -o out -B10, if the user chose to override my default to 10. Currently, this throws this error:

error: option '--max-lookback-blocks' cannot be specified more than once

If this behavior could be changed so that repeat options are accepted and override previous ones, it would be very appreciated.

Phantop avatar Apr 15 '22 17:04 Phantop

Mmmh, I understand where you're coming from, but... most of the time, this error can be quite useful, telling you that there's an inconsistency in the options you provided. My gut feeling is that the best solution here would be to parse the user input and handle -B (and other options where you want to provide different defaults) explicitly (in your project, that is).

This error is actually the default behaviour of Boost Program Options and I'm not entirely sure if this can be easily changed. I'd rather not make the code more complex for a single use case and at the same time take away useful error reporting.

So, I (subjectively) don't think this change would make a lot of sense. Feel free to convince me otherwise, but I might just close this one unless I can think of a compelling reason not to. :)

mhx avatar Apr 20 '22 06:04 mhx

I can see that justification but from my perspective I feel like quite a few CLI utilities I have used support multiple arguments in that manner. Just off the top of my head zstd certainly works that way, and if I run it with options like -18 -2 it will focus on the latter argument and use compression level 2.

Can't quite remember how most other programs respond to a situation like this but something in me says that what dwarfs does isn't the typical case. I might be wrong, and it's ultimately up to you regardless. I have a way to handle the argument anyways.

Phantop avatar Apr 20 '22 13:04 Phantop

Spent some more time looking into how this could be made to work. Long story short: it's a massive PITA. As I said before, this is more of a philosophical argument rather than a real bug and I'm personally leaning towards the behaviour that errors if you're potentially doing something silly. So I'm going to close this as wontfix.

mhx avatar Oct 29 '22 20:10 mhx