aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/output/output_interface.rs
blob: 661cd7fc239929471c78a714cc392ff439271557 (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
use crate::symfony::console::formatter::OutputFormatterInterface;
use crate::symfony::console::output::ConsoleOutputInterface;

pub trait OutputInterface: std::fmt::Debug {
    // PHP class semantics: OutputInterface methods take &self with interior mutability,
    // because output objects are shared by reference across the PHP code.
    fn write(&self, messages: &str, newline: bool, r#type: i64);
    fn writeln(&self, messages: &str, r#type: i64);
    fn set_verbosity(&self, level: i64);
    fn get_verbosity(&self) -> i64;
    fn is_quiet(&self) -> bool;
    fn is_verbose(&self) -> bool;
    fn is_very_verbose(&self) -> bool;
    fn is_debug(&self) -> bool;
    fn set_decorated(&self, decorated: bool);
    fn is_decorated(&self) -> bool;
    fn set_formatter(
        &self,
        formatter: std::rc::Rc<std::cell::RefCell<dyn OutputFormatterInterface>>,
    );
    fn get_formatter(&self) -> std::rc::Rc<std::cell::RefCell<dyn OutputFormatterInterface>>;

    /// PHP: `$output instanceof ConsoleOutputInterface`. Default false; ConsoleOutput overrides.
    fn is_console_output_interface(&self) -> bool {
        false
    }

    /// PHP: `$output instanceof ConsoleOutputInterface`. Returns the output as a
    /// ConsoleOutputInterface trait object when it is one. Default None; ConsoleOutput overrides.
    fn as_console_output_interface(&self) -> Option<&dyn ConsoleOutputInterface> {
        None
    }

    /// PHP: only StreamOutput exposes `getStream()`. Default panics for outputs without one.
    fn get_stream(&self) -> shirabe_php_shim::PhpResource {
        todo!("get_stream not available on this OutputInterface implementation")
    }
}

pub const VERBOSITY_QUIET: i64 = 16;
pub const VERBOSITY_NORMAL: i64 = 32;
pub const VERBOSITY_VERBOSE: i64 = 64;
pub const VERBOSITY_VERY_VERBOSE: i64 = 128;
pub const VERBOSITY_DEBUG: i64 = 256;

pub const OUTPUT_NORMAL: i64 = 1;
pub const OUTPUT_RAW: i64 = 2;
pub const OUTPUT_PLAIN: i64 = 4;