aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/about_command.rs
blob: 3e74d6ee1a648526853b6e17f66f96c303856ca0 (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
//! ref: composer/src/Composer/Command/AboutCommand.php

use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::HasBaseCommandData;
use crate::composer;
use crate::composer::ComposerHandle;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use shirabe_external_packages::symfony::component::console::input::InputInterface;
use shirabe_external_packages::symfony::component::console::output::OutputInterface;

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

impl AboutCommand {
    pub fn configure(&mut self) {
        self.set_name("about")
            .set_description("Shows a short information about Composer")
            .set_help("<info>php composer.phar about</info>");
    }

    pub fn execute(&mut self, input: &dyn InputInterface, output: &dyn OutputInterface) -> i64 {
        let composer_version = composer::get_version();
        let _ = (input, output);

        self.get_io().write(&format!(
            "<info>Composer - Dependency Manager for PHP - version {composer_version}</info>\n\
            <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.\n\
            See https://getcomposer.org/ for more information.</comment>"
        ));

        0
    }
}

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

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