aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/command
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/command')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/command.rs96
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs18
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/help_command.rs12
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/list_command.rs6
5 files changed, 69 insertions, 69 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/command.rs b/crates/shirabe-external-packages/src/symfony/console/command/command.rs
index 527f0c54..81eb3c08 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/command.rs
@@ -12,8 +12,7 @@ use crate::symfony::console::input::input_option::InputOption;
use crate::symfony::console::output::output_interface::{self, OutputInterface};
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
-use std::cell::{Cell, Ref, RefCell};
-use std::rc::Rc;
+use std::cell::{Cell, Ref};
/// The base-class state of the PHP `Command` class.
///
@@ -28,22 +27,23 @@ use std::rc::Rc;
/// command does not lock the object, so a command can be re-entered (e.g. the help command
/// describing itself) without the borrow conflicts a `&mut self` design would cause.
pub struct CommandData {
- application: RefCell<Option<Rc<RefCell<dyn Application>>>>,
- name: RefCell<Option<String>>,
- process_title: RefCell<Option<String>>,
- aliases: RefCell<Vec<String>>,
- definition: RefCell<Option<InputDefinition>>,
+ application: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<dyn Application>>>>,
+ name: std::cell::RefCell<Option<String>>,
+ process_title: std::cell::RefCell<Option<String>>,
+ aliases: std::cell::RefCell<Vec<String>>,
+ definition: std::cell::RefCell<Option<InputDefinition>>,
hidden: Cell<bool>,
- help: RefCell<String>,
- description: RefCell<String>,
- full_definition: RefCell<Option<InputDefinition>>,
+ help: std::cell::RefCell<String>,
+ description: std::cell::RefCell<String>,
+ full_definition: std::cell::RefCell<Option<InputDefinition>>,
ignore_validation_errors: Cell<bool>,
// A callable(InputInterface, OutputInterface) -> i64.
- code:
- RefCell<Option<Box<dyn Fn(&mut dyn InputInterface, &mut dyn OutputInterface) -> PhpMixed>>>,
- synopsis: RefCell<IndexMap<String, String>>,
- usages: RefCell<Vec<String>>,
- helper_set: RefCell<Option<Rc<RefCell<HelperSet>>>>,
+ code: std::cell::RefCell<
+ Option<Box<dyn Fn(&mut dyn InputInterface, &mut dyn OutputInterface) -> PhpMixed>>,
+ >,
+ synopsis: std::cell::RefCell<IndexMap<String, String>>,
+ usages: std::cell::RefCell<Vec<String>>,
+ helper_set: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>>,
}
impl CommandData {
@@ -81,22 +81,22 @@ impl CommandData {
/// virtual dispatch of `$this->configure()` from the parent constructor.
pub fn new(name: Option<String>) -> Self {
let this = CommandData {
- application: RefCell::new(None),
- name: RefCell::new(None),
- process_title: RefCell::new(None),
- aliases: RefCell::new(Vec::new()),
- definition: RefCell::new(Some(
+ application: std::cell::RefCell::new(None),
+ name: std::cell::RefCell::new(None),
+ process_title: std::cell::RefCell::new(None),
+ aliases: std::cell::RefCell::new(Vec::new()),
+ definition: std::cell::RefCell::new(Some(
InputDefinition::new(Vec::new()).expect("an empty InputDefinition cannot fail"),
)),
hidden: Cell::new(false),
- help: RefCell::new(String::new()),
- description: RefCell::new(String::new()),
- full_definition: RefCell::new(None),
+ help: std::cell::RefCell::new(String::new()),
+ description: std::cell::RefCell::new(String::new()),
+ full_definition: std::cell::RefCell::new(None),
ignore_validation_errors: Cell::new(false),
- code: RefCell::new(None),
- synopsis: RefCell::new(IndexMap::new()),
- usages: RefCell::new(Vec::new()),
- helper_set: RefCell::new(None),
+ code: std::cell::RefCell::new(None),
+ synopsis: std::cell::RefCell::new(IndexMap::new()),
+ usages: std::cell::RefCell::new(Vec::new()),
+ helper_set: std::cell::RefCell::new(None),
};
// PHP's __construct also derives the name from getDefaultName() when null and
@@ -345,8 +345,8 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
/// forgot to implement it (PHP throws LogicException — a programming error here).
fn execute(
&self,
- _input: Rc<RefCell<dyn InputInterface>>,
- _output: Rc<RefCell<dyn OutputInterface>>,
+ _input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
panic!("You must override the execute() method in the concrete command class.");
}
@@ -354,16 +354,16 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
/// Interacts with the user before the InputDefinition is validated.
fn interact(
&self,
- _input: Rc<RefCell<dyn InputInterface>>,
- _output: Rc<RefCell<dyn OutputInterface>>,
+ _input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) {
}
/// Initializes the command after the input has been bound and before it is validated.
fn initialize(
&self,
- _input: Rc<RefCell<dyn InputInterface>>,
- _output: Rc<RefCell<dyn OutputInterface>>,
+ _input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<()> {
Ok(())
}
@@ -387,8 +387,8 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
/// or that late binding breaks.
fn run(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
self.base_run(input, output)
}
@@ -399,8 +399,8 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
/// binding of `initialize`/`interact`/`execute` to the concrete command breaks.
fn base_run(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
// add the application arguments and options
self.merge_application_definition(true);
@@ -477,13 +477,16 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
fn is_enabled(&self) -> bool;
- fn set_application(&self, application: Option<Rc<RefCell<dyn Application>>>);
+ fn set_application(
+ &self,
+ application: Option<std::rc::Rc<std::cell::RefCell<dyn Application>>>,
+ );
- fn get_application(&self) -> Option<Rc<RefCell<dyn Application>>>;
+ fn get_application(&self) -> Option<std::rc::Rc<std::cell::RefCell<dyn Application>>>;
- fn set_helper_set(&self, helper_set: Rc<RefCell<HelperSet>>);
+ fn set_helper_set(&self, helper_set: std::rc::Rc<std::cell::RefCell<HelperSet>>);
- fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>>;
+ fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>;
fn merge_application_definition(&self, merge_args: bool);
@@ -549,7 +552,10 @@ impl Command for CommandData {
true
}
- fn set_application(&self, application: Option<Rc<RefCell<dyn Application>>>) {
+ fn set_application(
+ &self,
+ application: Option<std::rc::Rc<std::cell::RefCell<dyn Application>>>,
+ ) {
*self.application.borrow_mut() = application.clone();
if let Some(application) = application {
self.set_helper_set(application.borrow_mut().get_helper_set());
@@ -560,15 +566,15 @@ impl Command for CommandData {
*self.full_definition.borrow_mut() = None;
}
- fn get_application(&self) -> Option<Rc<RefCell<dyn Application>>> {
+ fn get_application(&self) -> Option<std::rc::Rc<std::cell::RefCell<dyn Application>>> {
self.application.borrow().clone()
}
- fn set_helper_set(&self, helper_set: Rc<RefCell<HelperSet>>) {
+ fn set_helper_set(&self, helper_set: std::rc::Rc<std::cell::RefCell<HelperSet>>) {
*self.helper_set.borrow_mut() = Some(helper_set);
}
- fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> {
+ fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> {
self.helper_set.borrow().clone()
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
index d64e4a99..5d8b1a98 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
@@ -11,9 +11,7 @@ use crate::symfony::console::input::input_option::InputOption;
use crate::symfony::console::output::output_interface::OutputInterface;
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
-use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
-use std::rc::Rc;
/// Responsible for providing the values to the shell completion.
#[derive(Debug)]
@@ -105,7 +103,7 @@ impl CompleteCommand {
&self,
completion_input: &CompletionInput,
_output: &dyn OutputInterface,
- ) -> Option<Rc<RefCell<dyn Command>>> {
+ ) -> Option<std::rc::Rc<std::cell::RefCell<dyn Command>>> {
// try { ... } catch (CommandNotFoundException $e) {}
let input_name = completion_input.get_first_argument()?;
@@ -144,14 +142,16 @@ impl CompleteCommand {
}
}
-fn get_class_of_command(command: &Rc<RefCell<dyn Command>>) -> String {
+fn get_class_of_command(command: &std::rc::Rc<std::cell::RefCell<dyn Command>>) -> String {
// LazyCommand is intentionally not ported.
// TODO: get_class() takes a PhpMixed but the command is a `dyn Command`; reflecting the
// concrete class name of a trait object requires a class-name hook on Command (Phase C).
todo!()
}
-fn get_definition_options(command: &Rc<RefCell<dyn Command>>) -> Vec<Rc<InputOption>> {
+fn get_definition_options(
+ command: &std::rc::Rc<std::cell::RefCell<dyn Command>>,
+) -> Vec<std::rc::Rc<InputOption>> {
command
.borrow()
.get_definition()
@@ -209,8 +209,8 @@ impl Command for CompleteCommand {
fn initialize(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<()> {
let _ = (input, output);
self.is_debug.set(shirabe_php_shim::filter_var_boolean(
@@ -224,8 +224,8 @@ impl Command for CompleteCommand {
fn execute(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
// try { ... } catch (\Throwable $e) { ...; if ($output->isDebug()) { throw $e; } return 2; }
let result: anyhow::Result<i64> = (|| {
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs
index 8e2583e9..23ce06f7 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs
@@ -10,9 +10,7 @@ use crate::symfony::console::input::input_interface::InputInterface;
use crate::symfony::console::input::input_option::InputOption;
use crate::symfony::console::output::output_interface::{self, OutputInterface};
use shirabe_php_shim::PhpMixed;
-use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
-use std::rc::Rc;
/// Dumps the completion script for the current shell.
#[derive(Debug)]
@@ -180,8 +178,8 @@ impl Command for DumpCompletionCommand {
fn execute(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
let command_name = shirabe_php_shim::basename(
&shirabe_php_shim::PHP_SERVER
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/help_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/help_command.rs
index 8ef488f7..7c32a733 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/help_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/help_command.rs
@@ -14,15 +14,13 @@ use crate::symfony::console::input::input_interface::InputInterface;
use crate::symfony::console::input::input_option::InputOption;
use crate::symfony::console::output::output_interface::OutputInterface;
use shirabe_php_shim::PhpMixed;
-use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
-use std::rc::Rc;
/// HelpCommand displays the help for a given command.
#[derive(Debug)]
pub struct HelpCommand {
inner: CommandData,
- command: RefCell<Option<Rc<RefCell<dyn Command>>>>,
+ command: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<dyn Command>>>>,
}
impl Deref for HelpCommand {
@@ -49,7 +47,7 @@ impl HelpCommand {
pub fn new() -> Self {
let command = HelpCommand {
inner: CommandData::new(None),
- command: RefCell::new(None),
+ command: std::cell::RefCell::new(None),
};
command
.configure()
@@ -57,7 +55,7 @@ impl HelpCommand {
command
}
- pub fn set_command(&self, command: Rc<RefCell<dyn Command>>) {
+ pub fn set_command(&self, command: std::rc::Rc<std::cell::RefCell<dyn Command>>) {
*self.command.borrow_mut() = Some(command);
}
@@ -135,8 +133,8 @@ impl Command for HelpCommand {
fn execute(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
if self.command.borrow().is_none() {
let application = self.get_application().unwrap();
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/list_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/list_command.rs
index 4f6e9231..4153a20b 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/list_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/list_command.rs
@@ -14,9 +14,7 @@ use crate::symfony::console::input::input_interface::InputInterface;
use crate::symfony::console::input::input_option::InputOption;
use crate::symfony::console::output::output_interface::OutputInterface;
use shirabe_php_shim::PhpMixed;
-use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
-use std::rc::Rc;
/// ListCommand displays the list of all available commands for the application.
#[derive(Debug)]
@@ -140,8 +138,8 @@ impl Command for ListCommand {
fn execute(
&self,
- input: Rc<RefCell<dyn InputInterface>>,
- output: Rc<RefCell<dyn OutputInterface>>,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
let mut helper = DescriptorHelper::new();
let object = DescribableObject::Application(self.get_application().unwrap());