aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/depends_command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/command/depends_command.rs')
-rw-r--r--crates/shirabe/src/command/depends_command.rs87
1 files changed, 23 insertions, 64 deletions
diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs
index 8a99ede..23b1d58 100644
--- a/crates/shirabe/src/command/depends_command.rs
+++ b/crates/shirabe/src/command/depends_command.rs
@@ -1,12 +1,7 @@
//! ref: composer/src/Composer/Command/DependsCommand.php
-use shirabe_external_packages::symfony::component::console::command::command::Command;
-use shirabe_external_packages::symfony::component::console::command::command::CommandBase;
-
-use crate::command::base_command::BaseCommand;
+use crate::command::base_command::{BaseCommand, BaseCommandData, HasBaseCommandData};
use crate::command::base_dependency_command::BaseDependencyCommand;
-use crate::command::completion_trait::CompletionTrait;
-use crate::composer::Composer;
use crate::console::input::input_argument::InputArgument;
use crate::console::input::input_option::InputOption;
use crate::io::io_interface::IOInterface;
@@ -15,55 +10,44 @@ use shirabe_external_packages::symfony::console::output::output_interface::Outpu
#[derive(Debug)]
pub struct DependsCommand {
- inner: CommandBase,
- composer: Option<Composer>,
- io: Option<Box<dyn IOInterface>>,
+ base_command_data: BaseCommandData,
colors: Vec<String>,
}
-impl CompletionTrait for DependsCommand {
- fn require_composer(
- &self,
- disable_plugins: Option<bool>,
- disable_scripts: Option<bool>,
- ) -> Composer {
- todo!()
- }
-}
-
impl DependsCommand {
pub fn configure(&mut self) {
- let package_suggestions = self.suggest_installed_package(true, true);
- self.inner
- .set_name("depends")
- .set_aliases(vec!["why".to_string()])
+ // TODO(cli-completion): suggest_installed_package(true, true) for `package` argument
+ self.set_name("depends")
+ .set_aliases(&["why".to_string()])
.set_description("Shows which packages cause the given package to be installed")
.set_definition(vec![
InputArgument::new(
BaseDependencyCommand::ARGUMENT_PACKAGE,
- InputArgument::REQUIRED,
+ Some(InputArgument::REQUIRED),
"Package to inspect",
None,
- package_suggestions,
),
InputOption::new(
BaseDependencyCommand::OPTION_RECURSIVE,
- Some("r"),
- InputOption::VALUE_NONE,
+ Some(shirabe_php_shim::PhpMixed::String("r".to_string())),
+ Some(InputOption::VALUE_NONE),
"Recursively resolves up to the root package",
+ None,
),
InputOption::new(
BaseDependencyCommand::OPTION_TREE,
- Some("t"),
- InputOption::VALUE_NONE,
+ Some(shirabe_php_shim::PhpMixed::String("t".to_string())),
+ Some(InputOption::VALUE_NONE),
"Prints the results as a nested tree",
+ None,
),
InputOption::new(
"locked",
None,
- InputOption::VALUE_NONE,
+ Some(InputOption::VALUE_NONE),
"Read dependency information from composer.lock",
+ None,
),
])
.set_help(
@@ -74,44 +58,19 @@ impl DependsCommand {
}
pub fn execute(&self, input: &dyn InputInterface, output: &dyn OutputInterface) -> i64 {
- self.inner.do_execute(input, output)
- }
-}
-
-impl BaseCommand for DependsCommand {
- fn inner(&self) -> &CommandBase {
- &self.inner
- }
-
- fn inner_mut(&mut self) -> &mut CommandBase {
- &mut self.inner
- }
-
- fn composer(&self) -> Option<&Composer> {
- self.composer.as_ref()
- }
-
- fn composer_mut(&mut self) -> &mut Option<Composer> {
- &mut self.composer
- }
-
- fn io(&self) -> Option<&dyn IOInterface> {
- self.io.as_deref()
- }
-
- fn io_mut(&mut self) -> &mut Option<Box<dyn IOInterface>> {
- &mut self.io
+ // TODO(phase-b): wire `do_execute` from BaseDependencyCommand trait without conflicting with
+ // BaseCommand blanket impl
+ let _ = (input, output);
+ todo!()
}
}
-impl BaseDependencyCommand for DependsCommand {
- fn colors(&self) -> &[String] {
- &self.colors
+impl HasBaseCommandData for DependsCommand {
+ fn base_command_data(&self) -> &BaseCommandData {
+ &self.base_command_data
}
- fn colors_mut(&mut self) -> &mut [String] {
- &mut self.colors
+ fn base_command_data_mut(&mut self) -> &mut BaseCommandData {
+ &mut self.base_command_data
}
}
-
-impl Command for DependsCommand {}