aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-symfony-console/src/formatter/output_formatter_interface.rs
blob: f2346ceb13181a1666bc528b02bf5749c2170047 (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
//! ref: composer/vendor/symfony/console/Formatter/OutputFormatterInterface.php

use crate::formatter::output_formatter_style_interface::OutputFormatterStyleInterface;

/// Formatter interface for console output.
pub trait OutputFormatterInterface: shirabe_php_shim::AsAny {
    /// Sets the decorated flag.
    fn set_decorated(&mut self, decorated: bool);

    /// Whether the output will decorate messages.
    fn is_decorated(&self) -> bool;

    /// Sets a new style.
    fn set_style(&mut self, name: &str, style: Box<dyn OutputFormatterStyleInterface>);

    /// Checks if output formatter has style with specified name.
    fn has_style(&self, name: &str) -> bool;

    /// Gets style options from style with specified name.
    ///
    /// Throws InvalidArgumentException when style isn't defined.
    fn get_style(
        &self,
        name: &str,
    ) -> anyhow::Result<std::rc::Rc<std::cell::RefCell<Box<dyn OutputFormatterStyleInterface>>>>;

    /// Formats a message according to the given styles.
    fn format(&mut self, message: Option<&str>) -> anyhow::Result<Option<String>>;
}