aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/application.rs
blob: 605851fe7afb95ba227f41d53826ce8cf21f56db (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/vendor/symfony/console/Application.php

use crate::symfony::console::command::command::Command;
use crate::symfony::console::completion::completion_input::CompletionInput;
use crate::symfony::console::completion::completion_suggestions::CompletionSuggestions;
use crate::symfony::console::helper::helper_set::HelperSet;
use crate::symfony::console::input::input_definition::InputDefinition;
use indexmap::IndexMap;
use std::cell::RefCell;
use std::rc::Rc;

/// `Symfony\Component\Console\Application` is a concrete class in PHP, but it is ported here as a
/// trait rather than a struct.
/// Refer to shirabe::console::Application for the reason.
pub trait Application: std::fmt::Debug + shirabe_php_shim::AsAny {
    fn get_name(&self) -> String;

    fn get_version(&self) -> String;

    fn get_help(&self) -> String;

    fn is_single_command(&self) -> bool;

    fn extract_namespace(&self, name: &str, limit: Option<i64>) -> String;

    fn find_namespace(&mut self, namespace: &str) -> anyhow::Result<String>;

    fn all(
        &mut self,
        namespace: Option<&str>,
    ) -> anyhow::Result<IndexMap<String, Rc<RefCell<dyn Command>>>>;

    fn find(&mut self, name: &str) -> anyhow::Result<Rc<RefCell<dyn Command>>>;

    fn get_definition(&mut self) -> Rc<RefCell<InputDefinition>>;

    fn get_helper_set(&mut self) -> Rc<RefCell<HelperSet>>;

    fn complete(
        &mut self,
        input: &CompletionInput,
        suggestions: &mut CompletionSuggestions,
    ) -> anyhow::Result<()>;
}