Closed AndreasBackx closed 7 months ago
I'm in support of all these changes. Can we just emit a warning or similar level claiming that custom encoding was passed but file inferred a different encoding.
Let's default to the custom provided encoding through --encoding
Let's default to the custom provided encoding through
--encoding
I suggest this because the user is explicitly providing the encoding which is the point of the flag regardless of the context inferred from the file name.
If there's any arguments against this, I'd love to hear them and find a better path forward.
@Shinyzenith --encoding
now is always used even if the extension is not the same. Then a warning is posted however:
➜ cargo run --release -- --encoding qoi something.png
Compiling wayshot v1.4.0-dev (/home/andreas/dev/wayshot-sapling/wayshot)
Finished release [optimized] target(s) in 1.01s
Running `target/release/wayshot --encoding qoi something.png`
2023-11-09T19:52:51.916179Z WARN wayshot: The encoding requested 'qoi' does not match the output file's encoding 'png'. Still using the requested encoding however.
ppm
is giving an error. Though I don't know enough about color types and image formats whether or not this is expected:
➜ cargo run --release -- --encoding ppm
Compiling wayshot v1.4.0-dev (/home/andreas/dev/wayshot-sapling/wayshot)
Finished release [optimized] target(s) in 1.00s
Running `target/release/wayshot --encoding ppm`
Error: The parameter is malformed: Color type can not be represented in the chosen format
Location:
wayshot/src/wayshot.rs:117:9
Improve CLI design
This "improves" (and that is subjective) the design of the CLI. I am aiming to get some feedback on what people think of the new design:
The main changes are:
--debug
is now--log-level
because this makes it easy to select more specifically what log level to use. I considered using-v
,-vv
... to increase verbosity but theclap-verbosity-crate
useslog
and nottracing
. We could use it somewhat, but we'd pull inlog
(which seems fine) and we'd need to map fromlog
's Level totracing
's Level enums (they use inverse ordering).--stdout
and--file
has been made an optional positional argument. This because it's what other CLIs often do and I wasn't sure what to call the option otherwise because--output
and-O
/-o
is often what others use but we use it here to refer to displays/monitors/Wayland outputs. This avoids that confusion hopefully and I've also clarified this in the documentation.jpg
tofoo.png
. Perhaps this behaviour can be changed, though I don't see a reason to support this weird edge case? When is someone savingpng
tojpg
?--extension
is--encoding
with aliases likeextension
.Again, let me know what you think.
Stack created with Sapling. Best reviewed with ReviewStack.
78
77
75
72
71