allow flatshape (command line syntax) theming (#502)

* allow flatshape (command line syntax) theming

* renamed crate, organized
This commit is contained in:
Darren Schroeder
2021-12-16 06:17:29 -06:00
committed by GitHub
parent 17a7a85c78
commit 9a864b5017
15 changed files with 379 additions and 162 deletions

View File

@ -2,6 +2,7 @@ use nu_protocol::ast::{
Block, Expr, Expression, ImportPatternMember, PathMember, Pipeline, Statement,
};
use nu_protocol::{engine::StateWorkingSet, Span};
use std::fmt::{Display, Formatter, Result};
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum FlatShape {
@ -24,6 +25,30 @@ pub enum FlatShape {
Custom(String),
}
impl Display for FlatShape {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
FlatShape::Garbage => write!(f, "flatshape_garbage"),
FlatShape::Bool => write!(f, "flatshape_bool"),
FlatShape::Int => write!(f, "flatshape_int"),
FlatShape::Float => write!(f, "flatshape_float"),
FlatShape::Range => write!(f, "flatshape_range"),
FlatShape::InternalCall => write!(f, "flatshape_internalcall"),
FlatShape::External => write!(f, "flatshape_external"),
FlatShape::ExternalArg => write!(f, "flatshape_externalarg"),
FlatShape::Literal => write!(f, "flatshape_literal"),
FlatShape::Operator => write!(f, "flatshape_operator"),
FlatShape::Signature => write!(f, "flatshape_signature"),
FlatShape::String => write!(f, "flatshape_string"),
FlatShape::Filepath => write!(f, "flatshape_filepath"),
FlatShape::GlobPattern => write!(f, "flatshape_globpattern"),
FlatShape::Variable => write!(f, "flatshape_variable"),
FlatShape::Flag => write!(f, "flatshape_flag"),
FlatShape::Custom(_) => write!(f, "flatshape_custom"),
}
}
}
pub fn flatten_block(working_set: &StateWorkingSet, block: &Block) -> Vec<(Span, FlatShape)> {
let mut output = vec![];
for stmt in &block.stmts {