aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/depends_command.rs
blob: 1e702e3256901706451cd11e354430c2fac480f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! ref: composer/src/Composer/Command/DependsCommand.php

use crate::command::BaseDependencyCommand;
use crate::command::{BaseCommand, BaseCommandData, HasBaseCommandData};
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterface;
use shirabe_external_packages::symfony::component::console::input::InputInterface;
use shirabe_external_packages::symfony::component::console::output::OutputInterface;

#[derive(Debug)]
pub struct DependsCommand {
    base_command_data: BaseCommandData,

    colors: Vec<String>,
}

impl DependsCommand {
    pub fn configure(&mut self) {
        // 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(&[
                InputArgument::new(
                    crate::command::ARGUMENT_PACKAGE,
                    Some(InputArgument::REQUIRED),
                    "Package to inspect",
                    None,
                )
                .unwrap()
                .into(),
                InputOption::new(
                    crate::command::OPTION_RECURSIVE,
                    Some(shirabe_php_shim::PhpMixed::String("r".to_string())),
                    Some(InputOption::VALUE_NONE),
                    "Recursively resolves up to the root package",
                    None,
                )
                .unwrap()
                .into(),
                InputOption::new(
                    crate::command::OPTION_TREE,
                    Some(shirabe_php_shim::PhpMixed::String("t".to_string())),
                    Some(InputOption::VALUE_NONE),
                    "Prints the results as a nested tree",
                    None,
                )
                .unwrap()
                .into(),
                InputOption::new(
                    "locked",
                    None,
                    Some(InputOption::VALUE_NONE),
                    "Read dependency information from composer.lock",
                    None,
                )
                .unwrap()
                .into(),
            ])
            .set_help(
                "Displays detailed information about where a package is referenced.\n\n\
                <info>php composer.phar depends composer/composer</info>\n\n\
                Read more at https://getcomposer.org/doc/03-cli.md#depends-why",
            );
    }

    pub fn execute(&mut self, input: &dyn InputInterface, output: &dyn OutputInterface) -> i64 {
        // TODO(phase-b): wire `do_execute` from BaseDependencyCommand trait without conflicting with
        // BaseCommand blanket impl
        let _ = (input, output);
        todo!()
    }
}

impl HasBaseCommandData for DependsCommand {
    fn base_command_data(&self) -> &BaseCommandData {
        &self.base_command_data
    }

    fn base_command_data_mut(&mut self) -> &mut BaseCommandData {
        &mut self.base_command_data
    }
}