mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FEATURE: Enforce that flags outputs must be a tuple.
This commit is contained in:
parent
1b2aa4dfd1
commit
17e22e5cf8
@ -18,6 +18,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
use crate::build::Val;
|
use crate::build::Val;
|
||||||
use crate::convert::traits::{ConvertResult, Converter};
|
use crate::convert::traits::{ConvertResult, Converter};
|
||||||
|
use crate::error::{BuildError, ErrorType};
|
||||||
|
|
||||||
/// FlagConverter implements the conversion logic for converting a Val into a set
|
/// FlagConverter implements the conversion logic for converting a Val into a set
|
||||||
/// of command line flags.
|
/// of command line flags.
|
||||||
@ -128,6 +129,12 @@ impl FlagConverter {
|
|||||||
|
|
||||||
impl Converter for FlagConverter {
|
impl Converter for FlagConverter {
|
||||||
fn convert(&self, v: Rc<Val>, mut w: &mut Write) -> ConvertResult {
|
fn convert(&self, v: Rc<Val>, mut w: &mut Write) -> ConvertResult {
|
||||||
|
if !v.is_tuple() {
|
||||||
|
return Err(Box::new(BuildError::new(
|
||||||
|
"Flag outputs must be a tuple",
|
||||||
|
ErrorType::ConvertError,
|
||||||
|
)));
|
||||||
|
}
|
||||||
self.write("", &v, &mut w)
|
self.write("", &v, &mut w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ pub enum ErrorType {
|
|||||||
ParseError,
|
ParseError,
|
||||||
AssertError,
|
AssertError,
|
||||||
OSError,
|
OSError,
|
||||||
|
// Conversion errors
|
||||||
|
ConvertError,
|
||||||
// User Defined Declarative Errors
|
// User Defined Declarative Errors
|
||||||
UserDefined,
|
UserDefined,
|
||||||
}
|
}
|
||||||
@ -56,6 +58,7 @@ impl fmt::Display for ErrorType {
|
|||||||
&ErrorType::ParseError => "ParseError",
|
&ErrorType::ParseError => "ParseError",
|
||||||
&ErrorType::AssertError => "AssertError",
|
&ErrorType::AssertError => "AssertError",
|
||||||
&ErrorType::OSError => "OSError",
|
&ErrorType::OSError => "OSError",
|
||||||
|
&ErrorType::ConvertError => "ConvertError",
|
||||||
&ErrorType::UserDefined => "UserDefined",
|
&ErrorType::UserDefined => "UserDefined",
|
||||||
};
|
};
|
||||||
w.write_str(name)
|
w.write_str(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user