diff options
Diffstat (limited to 'crates/shirabe/src/io')
| -rw-r--r-- | crates/shirabe/src/io/base_io.rs | 16 | ||||
| -rw-r--r-- | crates/shirabe/src/io/console_io.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/src/io/io_interface.rs | 16 | ||||
| -rw-r--r-- | crates/shirabe/src/io/null_io.rs | 38 |
4 files changed, 61 insertions, 20 deletions
diff --git a/crates/shirabe/src/io/base_io.rs b/crates/shirabe/src/io/base_io.rs index ddccd98..aa81d7b 100644 --- a/crates/shirabe/src/io/base_io.rs +++ b/crates/shirabe/src/io/base_io.rs @@ -1,6 +1,8 @@ //! ref: composer/src/Composer/IO/BaseIO.php use crate::config::Config; +use crate::io::io_interface; +use crate::io::io_interface; use crate::io::io_interface::IOInterface; use crate::util::process_executor::ProcessExecutor; use crate::util::silencer::Silencer; @@ -80,7 +82,7 @@ pub trait BaseIO: IOInterface { repository_name )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } self.set_authentication(repository_name, username, password); @@ -363,7 +365,7 @@ pub trait BaseIO: IOInterface { domain )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); continue; } @@ -483,28 +485,28 @@ pub trait BaseIO: IOInterface { self.write_error( PhpMixed::String(format!("<error>{}</error>", message_str)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if level_str == LogLevel::WARNING { self.write_error( PhpMixed::String(format!("<warning>{}</warning>", message_str)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if level_str == LogLevel::NOTICE { self.write_error( PhpMixed::String(format!("<info>{}</info>", message_str)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } else if level_str == LogLevel::INFO { self.write_error( PhpMixed::String(format!("<info>{}</info>", message_str)), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); } else { - self.write_error(PhpMixed::String(message_str), true, IOInterface::DEBUG); + self.write_error(PhpMixed::String(message_str), true, io_interface::DEBUG); } } } diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index f2c09ac..6a2edc7 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/IO/ConsoleIO.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::symfony::component::console::helper::helper_set::HelperSet; @@ -50,14 +51,14 @@ impl ConsoleIO { helper_set: HelperSet, ) -> Self { let mut verbosity_map = IndexMap::new(); - verbosity_map.insert(IOInterface::QUIET, OutputInterface::VERBOSITY_QUIET); - verbosity_map.insert(IOInterface::NORMAL, OutputInterface::VERBOSITY_NORMAL); - verbosity_map.insert(IOInterface::VERBOSE, OutputInterface::VERBOSITY_VERBOSE); + verbosity_map.insert(io_interface::QUIET, OutputInterface::VERBOSITY_QUIET); + verbosity_map.insert(io_interface::NORMAL, OutputInterface::VERBOSITY_NORMAL); + verbosity_map.insert(io_interface::VERBOSE, OutputInterface::VERBOSITY_VERBOSE); verbosity_map.insert( - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, OutputInterface::VERBOSITY_VERY_VERBOSE, ); - verbosity_map.insert(IOInterface::DEBUG, OutputInterface::VERBOSITY_DEBUG); + verbosity_map.insert(io_interface::DEBUG, OutputInterface::VERBOSITY_DEBUG); Self { inner: BaseIO { authentications: IndexMap::new(), diff --git a/crates/shirabe/src/io/io_interface.rs b/crates/shirabe/src/io/io_interface.rs index 446f47c..d66552d 100644 --- a/crates/shirabe/src/io/io_interface.rs +++ b/crates/shirabe/src/io/io_interface.rs @@ -5,13 +5,13 @@ use indexmap::IndexMap; use shirabe_external_packages::psr::log::logger_interface::LoggerInterface; use shirabe_php_shim::PhpMixed; -pub trait IOInterface: LoggerInterface { - const QUIET: i64 = 1; - const NORMAL: i64 = 2; - const VERBOSE: i64 = 4; - const VERY_VERBOSE: i64 = 8; - const DEBUG: i64 = 16; +pub const QUIET: i64 = 1; +pub const NORMAL: i64 = 2; +pub const VERBOSE: i64 = 4; +pub const VERY_VERBOSE: i64 = 8; +pub const DEBUG: i64 = 16; +pub trait IOInterface: LoggerInterface { fn is_interactive(&self) -> bool; fn is_verbose(&self) -> bool; @@ -65,11 +65,11 @@ pub trait IOInterface: LoggerInterface { fn get_authentication(&self, repository_name: &str) -> IndexMap<String, Option<String>>; fn set_authentication( - &self, + &mut self, repository_name: String, username: String, password: Option<String>, ); - fn load_configuration(&self, config: &Config); + fn load_configuration(&mut self, config: &Config); } diff --git a/crates/shirabe/src/io/null_io.rs b/crates/shirabe/src/io/null_io.rs index af0296d..66f7123 100644 --- a/crates/shirabe/src/io/null_io.rs +++ b/crates/shirabe/src/io/null_io.rs @@ -78,6 +78,44 @@ impl IOInterface for NullIO { ) -> PhpMixed { default } + + fn write_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64) { + <Self as BaseIO>::write_raw(self, messages, newline, verbosity) + } + + fn write_error_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64) { + <Self as BaseIO>::write_error_raw(self, messages, newline, verbosity) + } + + fn get_authentications( + &self, + ) -> indexmap::IndexMap<String, indexmap::IndexMap<String, Option<String>>> { + <Self as BaseIO>::get_authentications(self) + } + + fn has_authentication(&self, repository_name: &str) -> bool { + <Self as BaseIO>::has_authentication(self, repository_name) + } + + fn get_authentication( + &self, + repository_name: &str, + ) -> indexmap::IndexMap<String, Option<String>> { + <Self as BaseIO>::get_authentication(self, repository_name) + } + + fn set_authentication( + &mut self, + repository_name: String, + username: String, + password: Option<String>, + ) { + <Self as BaseIO>::set_authentication(self, repository_name, username, password) + } + + fn load_configuration(&mut self, config: &crate::config::Config) { + <Self as BaseIO>::load_configuration(self, config) + } } impl BaseIO for NullIO { |
