-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved CLI progress for ares-install
- Loading branch information
Showing
11 changed files
with
223 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ares-install" | ||
version = "0.1.3" | ||
version = "0.1.4" | ||
edition = "2021" | ||
authors = ["Mariotaku Lee <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
@@ -11,12 +11,13 @@ description = "Install or Remove app from a device" | |
[dependencies] | ||
common-device = { path = "../common/device" } | ||
common-connection = { path = "../common/connection" } | ||
clap = { version = "4.2.4", features = ["derive", "env"] } | ||
serde = { version = "1.0.160", features = ["derive"] } | ||
serde_json = "1.0.96" | ||
libssh-rs = { version = "0.2.0" } | ||
sha256 = "1.1.3" | ||
regex = "1.8.1" | ||
clap = { workspace = true, features = ["derive", "env"] } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json = { workspace = true } | ||
libssh-rs = { workspace = true } | ||
sha256 = { workspace = true } | ||
regex = { workspace = true } | ||
indicatif = { workspace = true } | ||
|
||
[package.metadata.deb] | ||
section = "devel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use regex::Regex; | ||
use serde::Serialize; | ||
|
||
use ares_connection_lib::luna::Luna; | ||
use ares_connection_lib::session::DeviceSession; | ||
|
||
use crate::install::{map_installer_message, InstallError}; | ||
|
||
pub(crate) trait RemoveApp { | ||
fn remove_app(&self, package_id: &str) -> Result<String, InstallError>; | ||
} | ||
|
||
#[derive(Serialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
struct RemovePayload { | ||
id: String, | ||
subscribe: bool, | ||
} | ||
|
||
impl RemoveApp for DeviceSession { | ||
fn remove_app(&self, package_id: &str) -> Result<String, InstallError> { | ||
let result = match self.subscribe( | ||
"luna://com.webos.appInstallService/dev/remove", | ||
RemovePayload { | ||
id: String::from(package_id), | ||
subscribe: true, | ||
}, | ||
true, | ||
) { | ||
Ok(subscription) => subscription | ||
.filter_map(|item| { | ||
map_installer_message(item, &Regex::new(r"(?i)removed").unwrap(), |progress| { | ||
println!("{}", progress); | ||
}) | ||
}) | ||
.next(), | ||
Err(e) => Some(Err(e.into())), | ||
}; | ||
|
||
return result.unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.