mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Add dir_path to crashreport ls
This commit is contained in:
@@ -79,13 +79,17 @@ impl CrashReportCopyMobileClient {
|
|||||||
|
|
||||||
/// Lists crash report files in the root of the crash logs directory.
|
/// Lists crash report files in the root of the crash logs directory.
|
||||||
///
|
///
|
||||||
|
/// # Arguments
|
||||||
|
/// * `dir_path` - The directory to pull logs from. Default is /
|
||||||
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// A list of filenames.
|
/// A list of filenames.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns `IdeviceError` if listing the directory fails.
|
/// Returns `IdeviceError` if listing the directory fails.
|
||||||
pub async fn ls(&mut self) -> Result<Vec<String>, IdeviceError> {
|
pub async fn ls(&mut self, dir_path: Option<&str>) -> Result<Vec<String>, IdeviceError> {
|
||||||
let mut res = self.afc_client.list_dir("/").await?;
|
let path = dir_path.unwrap_or("/");
|
||||||
|
let mut res = self.afc_client.list_dir(path).await?;
|
||||||
if res.len() > 2 {
|
if res.len() > 2 {
|
||||||
if &res[0] == "." {
|
if &res[0] == "." {
|
||||||
res.swap_remove(0);
|
res.swap_remove(0);
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ async fn main() {
|
|||||||
Command::new("pull")
|
Command::new("pull")
|
||||||
.about("Pulls a log")
|
.about("Pulls a log")
|
||||||
.arg(Arg::new("path").required(true).index(1))
|
.arg(Arg::new("path").required(true).index(1))
|
||||||
.arg(Arg::new("save").required(true).index(2)),
|
.arg(Arg::new("save").required(true).index(2))
|
||||||
|
.arg(Arg::new("dir").required(false).index(3)),
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
@@ -68,8 +69,12 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.expect("Unable to connect to misagent");
|
.expect("Unable to connect to misagent");
|
||||||
|
|
||||||
if let Some(_matches) = matches.subcommand_matches("list") {
|
if let Some(matches) = matches.subcommand_matches("list") {
|
||||||
let res = crash_client.ls().await.expect("Failed to read dir");
|
let dir_path: Option<&String> = matches.get_one("dir");
|
||||||
|
let res = crash_client
|
||||||
|
.ls(dir_path.map(|x| x.as_str()))
|
||||||
|
.await
|
||||||
|
.expect("Failed to read dir");
|
||||||
println!("{res:#?}");
|
println!("{res:#?}");
|
||||||
} else if matches.subcommand_matches("flush").is_some() {
|
} else if matches.subcommand_matches("flush").is_some() {
|
||||||
flush_reports(&*provider).await.expect("Failed to flush");
|
flush_reports(&*provider).await.expect("Failed to flush");
|
||||||
|
|||||||
Reference in New Issue
Block a user