diff options
Diffstat (limited to 'crates/shirabe/src/command/config_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/config_command.rs | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 7bf091a1..f1eb14b0 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -22,7 +22,7 @@ use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, escapeshellcmd, exec, explode, file_exists, impl_php_class, implode, in_array_loose, in_array_strict, is_array, is_bool, is_dir, is_numeric, is_object, is_string, json_encode, - php_regex, preg_match2, preg_replace, str_replace, strpos, strtolower, system, touch, + php_regex, preg_match, preg_replace, str_replace, strpos, strtolower, system, touch, var_export, }; use shirabe_semver::VersionParser; @@ -701,10 +701,9 @@ impl Command for ConfigCommand { let mut source = config.borrow_mut().get_source_of_value(&setting_key); let mut value: PhpMixed; - if let Some(matches) = preg_match2( + if let Some(matches) = preg_match( php_regex!("/^repos?(?:itories)?(?:\\.(.+))?/"), &setting_key, - 0, ) { if matches.get(1).is_none() { value = data @@ -925,9 +924,7 @@ impl Command for ConfigCommand { return Ok(0); } // handle preferred-install per-package config - if let Some(matches) = - preg_match2(php_regex!("/^preferred-install\\.(.+)/"), &setting_key, 0) - { + if let Some(matches) = preg_match(php_regex!("/^preferred-install\\.(.+)/"), &setting_key) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source .borrow_mut() @@ -960,10 +957,9 @@ impl Command for ConfigCommand { } // handle allow-plugins config setting elements true or false to add/remove - if let Some(matches) = preg_match2( + if let Some(matches) = preg_match( php_regex!("{^allow-plugins\\.([a-zA-Z0-9/*-]+)}"), &setting_key, - 0, ) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source @@ -1029,8 +1025,7 @@ impl Command for ConfigCommand { } // handle repositories - if let Some(matches) = - preg_match2(php_regex!("/^repos?(?:itories)?\\.(.+)/"), &setting_key, 0) + if let Some(matches) = preg_match(php_regex!("/^repos?(?:itories)?\\.(.+)/"), &setting_key) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source @@ -1099,7 +1094,7 @@ impl Command for ConfigCommand { } // handle extra - if let Some(matches) = preg_match2(php_regex!("/^extra\\.(.+)/"), &setting_key, 0) { + if let Some(matches) = preg_match(php_regex!("/^extra\\.(.+)/"), &setting_key) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source .borrow_mut() @@ -1171,7 +1166,7 @@ impl Command for ConfigCommand { } // handle suggest - if let Some(matches) = preg_match2(php_regex!("/^suggest\\.(.+)/"), &setting_key, 0) { + if let Some(matches) = preg_match(php_regex!("/^suggest\\.(.+)/"), &setting_key) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source .borrow_mut() @@ -1205,7 +1200,7 @@ impl Command for ConfigCommand { } // handle platform - if let Some(matches) = preg_match2(php_regex!("/^platform\\.(.+)/"), &setting_key, 0) { + if let Some(matches) = preg_match(php_regex!("/^platform\\.(.+)/"), &setting_key) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source .borrow_mut() @@ -1322,12 +1317,11 @@ impl Command for ConfigCommand { } // handle auth - if let Some(matches) = preg_match2( + if let Some(matches) = preg_match( php_regex!( "/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|custom-headers|bearer|forgejo-token)\\.(.+)/" ), &setting_key, - 0, ) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.auth_config_source @@ -1455,7 +1449,7 @@ impl Command for ConfigCommand { } // Check if the header is in correct "Name: Value" format - if preg_match2(php_regex!("/^[^:]+:\\s*.+$/"), header, 0).is_none() { + if preg_match(php_regex!("/^[^:]+:\\s*.+$/"), header).is_none() { return Err(RuntimeException::new(format!( "Header \"{}\" is not in \"Header-Name: Header-Value\" format", header @@ -1503,7 +1497,7 @@ impl Command for ConfigCommand { } // handle script - if let Some(matches) = preg_match2(php_regex!("/^scripts\\.(.+)/"), &setting_key, 0) { + if let Some(matches) = preg_match(php_regex!("/^scripts\\.(.+)/"), &setting_key) { if input.borrow().get_option("unset")?.as_bool() == Some(true) { self.config_source .borrow_mut() @@ -1742,10 +1736,9 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)> ( Box::new(|val| { PhpMixed::Bool( - preg_match2( + preg_match( php_regex!("/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i"), val.as_string().unwrap_or(""), - 0, ) .is_some(), ) |
