aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/dependency_resolver/operation/mark_alias_uninstalled_operation.rs
blob: 68f18c4e82e1629cec4ea6d0204f05c2bc3a30fd (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
//! ref: composer/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php

use crate::dependency_resolver::operation::operation_interface::OperationInterface;
use crate::dependency_resolver::operation::solver_operation::SolverOperation;
use crate::package::alias_package::AliasPackage;

#[derive(Debug)]
pub struct MarkAliasUninstalledOperation {
    pub(crate) package: AliasPackage,
}

impl MarkAliasUninstalledOperation {
    pub fn new(package: AliasPackage) -> Self {
        Self { package }
    }

    pub fn get_package(&self) -> &AliasPackage {
        &self.package
    }
}

impl SolverOperation for MarkAliasUninstalledOperation {
    const TYPE: &'static str = "markAliasUninstalled";
}

impl OperationInterface for MarkAliasUninstalledOperation {
    fn get_operation_type(&self) -> String {
        Self::TYPE.to_string()
    }

    fn show(&self, _lock: bool) -> String {
        format!(
            "Marking <info>{}</info> (<comment>{}</comment>) as uninstalled, alias of <info>{}</info> (<comment>{}</comment>)",
            self.package.get_pretty_name(),
            self.package.get_full_pretty_version(),
            self.package.get_alias_of().get_pretty_name(),
            self.package.get_alias_of().get_full_pretty_version(),
        )
    }

    fn to_string(&self) -> String {
        self.show(true)
    }
}