mirror of
https://github.com/nushell/nushell.git
synced 2025-05-29 06:17:54 +02:00
Fix flag oversight
This commit is contained in:
parent
72a61f557b
commit
9af08eb911
@ -93,32 +93,31 @@ pub fn enter(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
|
|
||||||
let mut stream = VecDeque::new();
|
let mut stream = VecDeque::new();
|
||||||
|
|
||||||
let file_extension = match args.nth(1) {
|
let file_extension = if args.has("raw") {
|
||||||
Some(Spanned {
|
None
|
||||||
item: Value::Primitive(Primitive::String(s)),
|
} else if args.has("json") {
|
||||||
span,
|
Some("json".to_string())
|
||||||
}) => {
|
} else if args.has("xml") {
|
||||||
if s == "--raw" {
|
Some("xml".to_string())
|
||||||
None
|
} else if args.has("ini") {
|
||||||
} else if s == "--json" {
|
Some("ini".to_string())
|
||||||
Some("json".to_string())
|
} else if args.has("yaml") {
|
||||||
} else if s == "--xml" {
|
Some("yaml".to_string())
|
||||||
Some("xml".to_string())
|
} else if args.has("toml") {
|
||||||
} else if s == "--ini" {
|
Some("toml".to_string())
|
||||||
Some("ini".to_string())
|
} else {
|
||||||
} else if s == "--yaml" {
|
if let Some(ref named_args) = args.args.named {
|
||||||
Some("yaml".to_string())
|
for named in named_args.iter() {
|
||||||
} else if s == "--toml" {
|
|
||||||
Some("toml".to_string())
|
|
||||||
} else {
|
|
||||||
return Err(ShellError::labeled_error(
|
return Err(ShellError::labeled_error(
|
||||||
"Unknown flag for open",
|
"Unknown flag for enter",
|
||||||
"unknown flag",
|
"unknown flag",
|
||||||
span.clone(),
|
named.1.span.clone(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
file_extension
|
||||||
|
} else {
|
||||||
|
file_extension
|
||||||
}
|
}
|
||||||
_ => file_extension,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match file_extension {
|
match file_extension {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use crate::errors::ShellError;
|
use crate::errors::ShellError;
|
||||||
use crate::object::{Primitive, Value};
|
use crate::object::{Primitive, Value};
|
||||||
|
use crate::parser::parse2::span::Spanned;
|
||||||
use crate::parser::registry::{CommandConfig, NamedType};
|
use crate::parser::registry::{CommandConfig, NamedType};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use crate::parser::parse2::span::Spanned;
|
|
||||||
|
|
||||||
pub struct Open;
|
pub struct Open;
|
||||||
|
|
||||||
@ -116,34 +116,32 @@ fn open(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
|
|
||||||
let mut stream = VecDeque::new();
|
let mut stream = VecDeque::new();
|
||||||
|
|
||||||
let file_extension = match args.nth(1) {
|
let file_extension = if args.has("raw") {
|
||||||
Some(Spanned {
|
None
|
||||||
item: Value::Primitive(Primitive::String(s)),
|
} else if args.has("json") {
|
||||||
span,
|
Some("json".to_string())
|
||||||
}) => {
|
} else if args.has("xml") {
|
||||||
if s == "--raw" {
|
Some("xml".to_string())
|
||||||
None
|
} else if args.has("ini") {
|
||||||
} else if s == "--json" {
|
Some("ini".to_string())
|
||||||
Some("json".to_string())
|
} else if args.has("yaml") {
|
||||||
} else if s == "--xml" {
|
Some("yaml".to_string())
|
||||||
Some("xml".to_string())
|
} else if args.has("toml") {
|
||||||
} else if s == "--ini" {
|
Some("toml".to_string())
|
||||||
Some("ini".to_string())
|
} else {
|
||||||
} else if s == "--yaml" {
|
if let Some(ref named_args) = args.args.named {
|
||||||
Some("yaml".to_string())
|
for named in named_args.iter() {
|
||||||
} else if s == "--toml" {
|
|
||||||
Some("toml".to_string())
|
|
||||||
} else {
|
|
||||||
return Err(ShellError::labeled_error(
|
return Err(ShellError::labeled_error(
|
||||||
"Unknown flag for open",
|
"Unknown flag for open",
|
||||||
"unknown flag",
|
"unknown flag",
|
||||||
span.clone(),
|
named.1.span.clone(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
file_extension
|
||||||
|
} else {
|
||||||
|
file_extension
|
||||||
}
|
}
|
||||||
_ => file_extension,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match file_extension {
|
match file_extension {
|
||||||
Some(x) if x == "toml" => {
|
Some(x) if x == "toml" => {
|
||||||
stream.push_back(ReturnValue::Value(
|
stream.push_back(ReturnValue::Value(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user