1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

add command to checkout branch in all apps

This commit is contained in:
Robin Appelman 2022-08-24 17:04:30 +02:00
commit 5278f0d295
5 changed files with 191 additions and 0 deletions

View file

@ -61,6 +61,9 @@ pub enum HazeArgs {
filter: Option<String>,
},
Proxy,
Checkout {
branch: String,
},
}
#[derive(Debug, Clone, Eq, PartialEq)]
@ -212,6 +215,13 @@ impl HazeArgs {
HazeCommand::Pin => Ok(HazeArgs::Pin { filter }),
HazeCommand::Unpin => Ok(HazeArgs::Unpin { filter }),
HazeCommand::Proxy => Ok(HazeArgs::Proxy),
HazeCommand::Checkout => {
let branch = args
.next()
.map(S::into)
.ok_or_else(|| Report::msg("No branch provided"))?;
Ok(HazeArgs::Checkout { branch })
}
}
}
}
@ -234,6 +244,7 @@ pub enum HazeCommand {
Pin,
Unpin,
Proxy,
Checkout,
}
impl FromStr for HazeCommand {
@ -258,6 +269,7 @@ impl FromStr for HazeCommand {
"pin" => Ok(HazeCommand::Pin),
"unpin" => Ok(HazeCommand::Unpin),
"proxy" => Ok(HazeCommand::Proxy),
"checkout" => Ok(HazeCommand::Checkout),
_ => Err(Report::msg(format!("Unknown command: {}", s))),
}
}
@ -282,6 +294,7 @@ impl HazeCommand {
HazeCommand::Pin => true,
HazeCommand::Unpin => true,
HazeCommand::Proxy => false,
HazeCommand::Checkout => false,
}
}
}