mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 16:15:20 +02:00
Convert table of primitives to positional arguments for external cmd (#2232)
* Convert table of primitives to positional arguments for external cmd * Multiple file test, fix for cococo
This commit is contained in:
@ -62,9 +62,29 @@ async fn run_with_stdin(
|
||||
}
|
||||
|
||||
// Do the cleanup that we need to do on any argument going out:
|
||||
let trimmed_value_string = value.as_string()?.trim_end_matches('\n').to_string();
|
||||
|
||||
command_args.push(trimmed_value_string);
|
||||
match &value.value {
|
||||
UntaggedValue::Table(table) => {
|
||||
for t in table {
|
||||
match &t.value {
|
||||
UntaggedValue::Primitive(_) => {
|
||||
command_args
|
||||
.push(t.convert_to_string().trim_end_matches('\n').to_string());
|
||||
}
|
||||
_ => {
|
||||
return Err(ShellError::labeled_error(
|
||||
"Could not convert to positional arguments",
|
||||
"could not convert to positional arguments",
|
||||
value.tag(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let trimmed_value_string = value.as_string()?.trim_end_matches('\n').to_string();
|
||||
command_args.push(trimmed_value_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let process_args = command_args
|
||||
|
@ -7,12 +7,7 @@ pub fn cococo() {
|
||||
// Write back out all the arguments passed
|
||||
// if given at least 1 instead of chickens
|
||||
// speaking co co co.
|
||||
let mut arguments = args.iter();
|
||||
arguments.next();
|
||||
|
||||
for arg in arguments {
|
||||
println!("{}", &arg);
|
||||
}
|
||||
println!("{}", &args[1..].join(" "));
|
||||
} else {
|
||||
println!("cococo");
|
||||
}
|
||||
|
Reference in New Issue
Block a user