Skip to content

Commit

Permalink
Rewrite argument parsing to use Clap's derives
Browse files Browse the repository at this point in the history
This is something that has been on the radar for a while, but the recent
deprecation of everything from Clap 3.1 in Clap 3.2 has pushed our hand
a bit to get it done now with the new best practices from Clap 3.2.
  • Loading branch information
shssoichiro committed Jun 26, 2022
1 parent a8d1e46 commit 1de2abc
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 556 deletions.
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ dump_lookahead_data = ["byteorder", "image"]
arg_enum_proc_macro = "0.3"
bitstream-io = "1"
cfg-if = "1.0"
clap = { version = "3.1", optional = true, default-features = false, features = [
"color",
"std",
"wrap_help",
] }
clap = { version = "3.2.6", optional = true, default-features = false, features = ["color", "std", "wrap_help", "derive"] }
clap_complete = { version = "3", optional = true }
libc = "0.2"
y4m = { version = "0.7", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions src/api/config/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub struct EncoderConfig {
/// [`with_speed_preset()`]: struct.EncoderConfig.html#method.with_speed_preset
impl Default for EncoderConfig {
fn default() -> Self {
const DEFAULT_SPEED: usize = 6;
const DEFAULT_SPEED: u8 = 6;
Self::with_speed_preset(DEFAULT_SPEED)
}
}
Expand All @@ -130,7 +130,7 @@ impl EncoderConfig {
/// than 10, it will result in the same settings as 10.
///
/// [`from_preset()`]: struct.SpeedSettings.html#method.from_preset
pub fn with_speed_preset(speed: usize) -> Self {
pub fn with_speed_preset(speed: u8) -> Self {
EncoderConfig {
width: 640,
height: 480,
Expand Down
2 changes: 1 addition & 1 deletion src/api/config/speedsettings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Default for SpeedSettings {

impl SpeedSettings {
/// Set the speed setting according to a numeric speed preset.
pub fn from_preset(speed: usize) -> Self {
pub fn from_preset(speed: u8) -> Self {
// The default settings are equivalent to speed 0
let mut settings = SpeedSettings::default();

Expand Down
Loading

0 comments on commit 1de2abc

Please sign in to comment.