mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
feat(springboard): add wallpaper preview command support (#64)
* feat(springboard): add wallpaper preview command support * Use subargs to switch between preview type in sb cli --------- Co-authored-by: Jackson Coxson <jkcoxson@gmail.com>
This commit is contained in:
@@ -32,6 +32,19 @@ pub fn register() -> JkCommand {
|
||||
.required(true),
|
||||
),
|
||||
)
|
||||
.with_subcommand(
|
||||
"get_wallpaper_preview",
|
||||
JkCommand::new()
|
||||
.help("Gets wallpaper preview")
|
||||
.with_subcommand("homescreen", JkCommand::new())
|
||||
.with_subcommand("lockscreen", JkCommand::new())
|
||||
.subcommand_required(true)
|
||||
.with_flag(
|
||||
JkFlag::new("save")
|
||||
.with_help("Path to save the wallpaper PNG file, or preview.png by default")
|
||||
.with_argument(JkArgument::new().required(true)),
|
||||
),
|
||||
)
|
||||
.subcommand_required(true)
|
||||
}
|
||||
|
||||
@@ -71,6 +84,24 @@ pub async fn main(arguments: &CollectedArguments, provider: Box<dyn IdeviceProvi
|
||||
.await
|
||||
.expect("Failed to set icon state");
|
||||
}
|
||||
"get_wallpaper_preview" => {
|
||||
let (wallpaper_type, _) = sub_args.first_subcommand().unwrap();
|
||||
|
||||
let wallpaper = match wallpaper_type.as_str() {
|
||||
"homescreen" => sbc.get_home_screen_wallpaper_preview_pngdata().await,
|
||||
"lockscreen" => sbc.get_lock_screen_wallpaper_preview_pngdata().await,
|
||||
_ => panic!("Invalid wallpaper type. Use 'homescreen' or 'lockscreen'"),
|
||||
}
|
||||
.expect("Failed to get wallpaper preview");
|
||||
|
||||
let save_path = sub_args
|
||||
.get_flag::<String>("save")
|
||||
.unwrap_or("preview.png".to_string());
|
||||
|
||||
tokio::fs::write(&save_path, wallpaper)
|
||||
.await
|
||||
.expect("Failed to save wallpaper");
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user