mirror of
https://github.com/nushell/nushell.git
synced 2025-08-12 14:08:11 +02:00
Tests pass
This commit is contained in:
@ -4,22 +4,15 @@ use getset::Getters;
|
||||
use serde::{Serialize, Serializer};
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
#[derive(new, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Deserialize, Hash, Getters)]
|
||||
#[derive(
|
||||
new, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash, Getters,
|
||||
)]
|
||||
#[get = "crate"]
|
||||
pub struct Spanned<T> {
|
||||
pub span: Span,
|
||||
pub item: T,
|
||||
}
|
||||
|
||||
impl<T: Serialize> Serialize for Spanned<T> {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
self.item.serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Spanned<T> {
|
||||
pub fn spanned(self, span: impl Into<Span>) -> Spanned<T> {
|
||||
Spanned::from_item(self.item, span.into())
|
||||
|
@ -40,18 +40,19 @@ pub enum PositionalType {
|
||||
Optional(String, PositionalValue),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum PositionalValue {
|
||||
Value,
|
||||
Block,
|
||||
}
|
||||
|
||||
impl PositionalType {
|
||||
crate fn mandatory(name: &str, kind: &str) -> PositionalType {
|
||||
match kind {
|
||||
"Block" => PositionalType::Mandatory(name.to_string(), PositionalValue::Block),
|
||||
_ => PositionalType::Mandatory(name.to_string(), PositionalValue::Value),
|
||||
}
|
||||
pub fn mandatory(name: &str) -> PositionalType {
|
||||
PositionalType::Mandatory(name.to_string(), PositionalValue::Value)
|
||||
}
|
||||
|
||||
pub fn mandatory_block(name: &str) -> PositionalType {
|
||||
PositionalType::Mandatory(name.to_string(), PositionalValue::Block)
|
||||
}
|
||||
|
||||
crate fn to_coerce_hint(&self) -> Option<ExpressionKindHint> {
|
||||
@ -76,7 +77,7 @@ impl PositionalType {
|
||||
#[get = "crate"]
|
||||
pub struct CommandConfig {
|
||||
pub name: String,
|
||||
crate positional: Vec<PositionalType>,
|
||||
pub positional: Vec<PositionalType>,
|
||||
pub rest_positional: bool,
|
||||
pub named: IndexMap<String, NamedType>,
|
||||
pub is_filter: bool,
|
||||
|
Reference in New Issue
Block a user