diff options
Diffstat (limited to 'crates/shirabe/src')
| -rw-r--r-- | crates/shirabe/src/command/archive_command.rs | 13 | ||||
| -rw-r--r-- | crates/shirabe/src/command/audit_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/base_config_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/dump_autoload_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/exec_command.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/command/install_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/reinstall_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/remove_command.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/command/run_script_command.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/command/search_command.rs | 7 | ||||
| -rw-r--r-- | crates/shirabe/src/command/update_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/validate_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/json/json_manipulator.rs | 14 | ||||
| -rw-r--r-- | crates/shirabe/src/util/filesystem.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/src/util/url.rs | 4 |
15 files changed, 38 insertions, 40 deletions
diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs index c823860..01da89d 100644 --- a/crates/shirabe/src/command/archive_command.rs +++ b/crates/shirabe/src/command/archive_command.rs @@ -90,7 +90,7 @@ impl ArchiveCommand { let format = input .get_option("format") - .as_string_opt() + .as_string() .map(|s| s.to_string()) .unwrap_or_else(|| { config @@ -103,7 +103,7 @@ impl ArchiveCommand { let dir = input .get_option("dir") - .as_string_opt() + .as_string() .map(|s| s.to_string()) .unwrap_or_else(|| { config @@ -121,18 +121,15 @@ impl ArchiveCommand { &config, input .get_argument("package") - .as_string_opt() + .as_string() .map(|s| s.to_string()), input .get_argument("version") - .as_string_opt() + .as_string() .map(|s| s.to_string()), &format, &dir, - input - .get_option("file") - .as_string_opt() - .map(|s| s.to_string()), + input.get_option("file").as_string().map(|s| s.to_string()), input .get_option("ignore-filters") .as_bool() diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index e814821..f4f27e9 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -86,7 +86,7 @@ impl AuditCommand { let abandoned = input .get_option("abandoned") - .as_string_opt() + .as_string() .map(|s| s.to_string()); if abandoned.is_some() && !in_array( diff --git a/crates/shirabe/src/command/base_config_command.rs b/crates/shirabe/src/command/base_config_command.rs index 081120d..2da93dc 100644 --- a/crates/shirabe/src/command/base_config_command.rs +++ b/crates/shirabe/src/command/base_config_command.rs @@ -108,7 +108,7 @@ pub trait BaseConfigCommand: BaseCommand { } else { input .get_option("file") - .as_string_opt() + .as_string() .map(|s| s.to_string()) .unwrap_or_else(|| Factory::get_composer_file().unwrap_or_default()) } diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs index 588c91e..275e635 100644 --- a/crates/shirabe/src/command/dump_autoload_command.rs +++ b/crates/shirabe/src/command/dump_autoload_command.rs @@ -94,7 +94,7 @@ impl DumpAutoloadCommand { .unwrap_or(false); let apcu_prefix = input .get_option("apcu-prefix") - .as_string_opt() + .as_string() .map(|s| s.to_string()); let apcu = apcu_prefix.is_some() || input.get_option("apcu").as_bool().unwrap_or(false) diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index 68e2d0f..23aa103 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -48,7 +48,7 @@ impl ExecCommand { return Ok(()); } - if input.get_argument("binary").as_string_opt().is_some() + if input.get_argument("binary").as_string().is_some() || input.get_option("list").as_bool().unwrap_or(false) { return Ok(()); @@ -82,7 +82,7 @@ impl ExecCommand { let composer = self.require_composer(None, None)?; if input.get_option("list").as_bool().unwrap_or(false) - || input.get_argument("binary").as_string_opt().is_none() + || input.get_argument("binary").as_string().is_none() { let bins = self.get_binaries(true)?; if bins.is_empty() { diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs index 632ccb1..a0710dc 100644 --- a/crates/shirabe/src/command/install_command.rs +++ b/crates/shirabe/src/command/install_command.rs @@ -140,7 +140,7 @@ impl InstallCommand { .unwrap_or(false); let apcu_prefix = input .get_option("apcu-autoloader-prefix") - .as_string_opt() + .as_string() .map(|s| s.to_string()); let apcu = apcu_prefix.is_some() || input diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs index 8bb4643..d66a830 100644 --- a/crates/shirabe/src/command/reinstall_command.rs +++ b/crates/shirabe/src/command/reinstall_command.rs @@ -255,7 +255,7 @@ impl ReinstallCommand { .unwrap_or(false); let apcu_prefix = input .get_option("apcu-autoloader-prefix") - .as_string_opt() + .as_string() .map(|s| s.to_string()); let apcu = apcu_prefix.is_some() || input diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index ab322f9..49b21dc 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -477,7 +477,7 @@ impl RemoveCommand { let allow_plugins = composer.get_config().borrow_mut().get("allow-plugins"); let removed_plugins: Vec<String> = - if let Some(allow_map) = allow_plugins.as_ref().and_then(|v| v.as_array()) { + if let Some(allow_map) = allow_plugins.as_opt().and_then(|v| v.as_array()) { packages .iter() .filter(|p| allow_map.contains_key(p.as_str())) @@ -488,11 +488,11 @@ impl RemoveCommand { }; if !dry_run - && allow_plugins.as_ref().and_then(|v| v.as_array()).is_some() + && allow_plugins.as_opt().and_then(|v| v.as_array()).is_some() && !removed_plugins.is_empty() { let allow_map_len = allow_plugins - .as_ref() + .as_opt() .and_then(|v| v.as_array()) .map(|m| m.len()) .unwrap_or(0); diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index 436d906..e58ad24 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -122,7 +122,7 @@ impl RunScriptCommand { return Ok(()); } - if input.get_argument("script").as_string_opt().is_some() + if input.get_argument("script").as_string().is_some() || input.get_option("list").as_bool().unwrap_or(false) { return Ok(()); @@ -160,7 +160,7 @@ impl RunScriptCommand { return self.list_scripts(output); } - let script = match input.get_argument("script").as_string_opt() { + let script = match input.get_argument("script").as_string() { None => { return Err(RuntimeException { message: "Missing required argument \"script\"".to_string(), @@ -209,7 +209,7 @@ impl RunScriptCommand { }) .unwrap_or_default(); - if let Some(timeout_val) = input.get_option("timeout").as_string_opt() { + if let Some(timeout_val) = input.get_option("timeout").as_string() { let timeout_str = timeout_val.to_string(); if !timeout_str.chars().all(|c| c.is_ascii_digit()) { return Err(RuntimeException { diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index fb6b047..9375ec7 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -51,7 +51,7 @@ impl SearchCommand { let format = input .get_option("format") - .as_string_opt() + .as_string() .map(|s| s.to_string()) .unwrap_or_else(|| "text".to_string()); if !in_array( @@ -114,10 +114,7 @@ impl SearchCommand { mode = repository_interface::SEARCH_VENDOR; } - let r#type = input - .get_option("type") - .as_string_opt() - .map(|s| s.to_string()); + let r#type = input.get_option("type").as_string().map(|s| s.to_string()); let tokens_arg = input.get_argument("tokens"); let token_strings: Vec<String> = tokens_arg diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index b96793d..c4ae890 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -341,7 +341,7 @@ impl UpdateCommand { .unwrap_or(false); let apcu_prefix: Option<String> = input .get_option("apcu-autoloader-prefix") - .as_string_opt() + .as_string() .map(|s| s.to_string()); let apcu = apcu_prefix.is_some() || input diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs index f57c21c..60514a1 100644 --- a/crates/shirabe/src/command/validate_command.rs +++ b/crates/shirabe/src/command/validate_command.rs @@ -114,7 +114,7 @@ impl ValidateCommand { ) -> Result<i64> { let file = input .get_argument("file") - .as_string_opt() + .as_string() .map(|s| s.to_string()) .map(Ok) .unwrap_or_else(Factory::get_composer_file)?; diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs index c9ca7f7..e5510d3 100644 --- a/crates/shirabe/src/json/json_manipulator.rs +++ b/crates/shirabe/src/json/json_manipulator.rs @@ -269,7 +269,7 @@ impl JsonManipulator { .and_then(|o| o.to_array().get("repositories").cloned()); let is_std_class = repositories_value .as_ref() - .map(|v| v.as_any().is::<StdClass>()) + .map(|v| (&**v as &dyn std::any::Any).is::<StdClass>()) .unwrap_or(false); if is_std_class { @@ -290,7 +290,7 @@ impl JsonManipulator { // re-add in order for (repository_name, repository) in &repos_arr { - let is_obj = repository.as_any().is::<StdClass>(); + let is_obj = (&**repository as &dyn std::any::Any).is::<StdClass>(); if !is_obj { let mut m: IndexMap<String, Box<PhpMixed>> = IndexMap::new(); m.insert(repository_name.clone(), repository.clone()); @@ -515,7 +515,7 @@ impl JsonManipulator { .and_then(|o| o.to_array().get("repositories").cloned()); let is_assoc = repositories_value .as_ref() - .map(|v| v.as_any().is::<StdClass>()) + .map(|v| (&**v as &dyn std::any::Any).is::<StdClass>()) .unwrap_or(false); let repos: IndexMap<String, Box<PhpMixed>> = repositories_value @@ -1689,7 +1689,9 @@ impl JsonManipulator { pub fn format(&self, data: &PhpMixed, depth: i64, was_object: bool) -> anyhow::Result<String> { let mut data = data.clone(); let mut was_object = was_object; - if data.as_any().is::<StdClass>() || data.as_any().is::<ArrayObject>() { + if (&data as &dyn std::any::Any).is::<StdClass>() + || (&data as &dyn std::any::Any).is::<ArrayObject>() + { // PHP: (array) $data — coerce to array if let Some(obj) = data.as_object() { data = PhpMixed::Array(obj.to_array()); @@ -1761,7 +1763,9 @@ impl ManipulatorFormatter { fn format(&self, data: &PhpMixed, depth: i64, was_object: bool) -> anyhow::Result<String> { let mut data = data.clone(); let mut was_object = was_object; - if data.as_any().is::<StdClass>() || data.as_any().is::<ArrayObject>() { + if (&data as &dyn std::any::Any).is::<StdClass>() + || (&data as &dyn std::any::Any).is::<ArrayObject>() + { if let Some(obj) = data.as_object() { data = PhpMixed::Array(obj.to_array()); } diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs index a51b0f3..96316e9 100644 --- a/crates/shirabe/src/util/filesystem.rs +++ b/crates/shirabe/src/util/filesystem.rs @@ -419,7 +419,7 @@ impl Filesystem { if str_contains(&e.message, "Bad address") { let source_handle = fopen(source, "r"); let target_handle = fopen(&target, "w"); - if source_handle.is_none() || target_handle.is_none() { + if source_handle.is_null() || target_handle.is_null() { return Err(e.into()); } while !feof(source_handle.clone()) { @@ -1035,14 +1035,14 @@ impl Filesystem { pub fn safe_copy(&self, source: &str, target: &str) -> anyhow::Result<()> { if !file_exists(target) || !file_exists(source) || !self.files_are_equal(source, target) { let source_handle = fopen(source, "r"); - if source_handle.is_none() { + if source_handle.is_null() { return Err(anyhow::anyhow!( "Could not open \"{}\" for reading.", source )); } let target_handle = fopen(target, "w+"); - if target_handle.is_none() { + if target_handle.is_null() { return Err(anyhow::anyhow!( "Could not open \"{}\" for writing.", target @@ -1070,11 +1070,11 @@ impl Filesystem { // Check if content is different let a_handle = fopen(a, "rb"); - if a_handle.is_none() { + if a_handle.is_null() { return false; } let b_handle = fopen(b, "rb"); - if b_handle.is_none() { + if b_handle.is_null() { return false; } diff --git a/crates/shirabe/src/util/url.rs b/crates/shirabe/src/util/url.rs index a6736aa..8bcd73e 100644 --- a/crates/shirabe/src/util/url.rs +++ b/crates/shirabe/src/util/url.rs @@ -11,7 +11,7 @@ pub struct Url; impl Url { pub fn update_dist_reference(config: &Config, mut url: String, r#ref: &str) -> String { let host = parse_url(&url, PHP_URL_HOST) - .as_string_opt() + .as_string() .map(|s| s.to_string()) .unwrap_or_default(); @@ -128,7 +128,7 @@ impl Url { } let mut origin = parse_url(url, PHP_URL_HOST) - .as_string_opt() + .as_string() .map(|s| s.to_string()) .unwrap_or_default(); if let Some(port) = parse_url(url, PHP_URL_PORT).as_int() { |
