aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-symfony-console/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-symfony-console/src/command')
-rw-r--r--crates/shirabe-symfony-console/src/command/complete_command.rs23
-rw-r--r--crates/shirabe-symfony-console/src/command/help_command.rs10
-rw-r--r--crates/shirabe-symfony-console/src/command/list_command.rs15
3 files changed, 35 insertions, 13 deletions
diff --git a/crates/shirabe-symfony-console/src/command/complete_command.rs b/crates/shirabe-symfony-console/src/command/complete_command.rs
index dc418178..432888b6 100644
--- a/crates/shirabe-symfony-console/src/command/complete_command.rs
+++ b/crates/shirabe-symfony-console/src/command/complete_command.rs
@@ -78,19 +78,26 @@ impl CompleteCommand {
input: &dyn InputInterface,
) -> anyhow::Result<CompletionInput> {
let current_index = input.get_option("current")?;
- if !current_index.to_bool() || !shirabe_php_shim::ctype_digit(&current_index.to_string()) {
+ if !current_index.to_bool()
+ || !shirabe_php_shim::ctype_digit(current_index.as_string().unwrap_or_default())
+ {
anyhow::bail!(shirabe_php_shim::RuntimeException::new(
"The \"--current\" option must be set and it must be an integer.".to_string()
));
}
- let tokens: Vec<String> = match input.get_option("input")?.as_list() {
- Some(list) => list.iter().map(|v| v.to_string()).collect(),
- None => Vec::new(),
- };
+ let tokens: Vec<String> = input
+ .get_option("input")?
+ .as_array()
+ .map(<[String]>::to_vec)
+ .unwrap_or_default();
let mut completion_input = CompletionInput::from_tokens(
tokens,
- current_index.to_string().parse::<i64>().unwrap_or(0),
+ current_index
+ .as_string()
+ .unwrap_or_default()
+ .parse::<i64>()
+ .unwrap_or(0),
)?;
// try { $completionInput->bind(...); } catch (ExceptionInterface $e) {}
@@ -254,13 +261,13 @@ impl Command for CompleteCommand {
let completion_output = self
.completion_outputs
- .get(&shell.to_string())
+ .get(shell.as_string().unwrap_or_default())
.cloned()
.unwrap_or(PhpMixed::Bool(false));
if !completion_output.to_bool() {
anyhow::bail!(shirabe_php_shim::RuntimeException::new(format!(
"Shell completion is not supported for your shell: \"{}\" (supported: \"{}\").",
- shell,
+ shell.as_string().unwrap_or_default(),
self.completion_outputs
.keys()
.cloned()
diff --git a/crates/shirabe-symfony-console/src/command/help_command.rs b/crates/shirabe-symfony-console/src/command/help_command.rs
index 4f1447cb..2081e0e1 100644
--- a/crates/shirabe-symfony-console/src/command/help_command.rs
+++ b/crates/shirabe-symfony-console/src/command/help_command.rs
@@ -149,8 +149,14 @@ impl Command for HelpCommand {
let mut helper = DescriptorHelper::new();
let object = DescribableObject::Command(self.command.borrow().clone().unwrap());
let mut options = indexmap::IndexMap::new();
- options.insert("format".to_string(), input.borrow().get_option("format")?);
- options.insert("raw_text".to_string(), input.borrow().get_option("raw")?);
+ options.insert(
+ "format".to_string(),
+ input.borrow().get_option("format")?.into(),
+ );
+ options.insert(
+ "raw_text".to_string(),
+ input.borrow().get_option("raw")?.into(),
+ );
helper.describe2(output.clone(), object, options)?;
*self.command.borrow_mut() = None;
diff --git a/crates/shirabe-symfony-console/src/command/list_command.rs b/crates/shirabe-symfony-console/src/command/list_command.rs
index ead84d44..6074b49a 100644
--- a/crates/shirabe-symfony-console/src/command/list_command.rs
+++ b/crates/shirabe-symfony-console/src/command/list_command.rs
@@ -147,13 +147,22 @@ impl Command for ListCommand {
let mut helper = DescriptorHelper::new();
let object = DescribableObject::Application(self.get_application().unwrap());
let mut options = indexmap::IndexMap::new();
- options.insert("format".to_string(), input.borrow().get_option("format")?);
- options.insert("raw_text".to_string(), input.borrow().get_option("raw")?);
+ options.insert(
+ "format".to_string(),
+ input.borrow().get_option("format")?.into(),
+ );
+ options.insert(
+ "raw_text".to_string(),
+ input.borrow().get_option("raw")?.into(),
+ );
options.insert(
"namespace".to_string(),
input.borrow().get_argument("namespace")?,
);
- options.insert("short".to_string(), input.borrow().get_option("short")?);
+ options.insert(
+ "short".to_string(),
+ input.borrow().get_option("short")?.into(),
+ );
helper.describe2(output.clone(), object, options)?;
Ok(0)