2019-11-10 23:17:47 -08:00
|
|
|
use crate::common::*;
|
|
|
|
|
2021-06-08 01:01:27 -07:00
|
|
|
#[derive(Debug, Clone)]
|
2019-11-10 23:17:47 -08:00
|
|
|
pub(crate) enum Setting<'src> {
|
2021-03-28 22:38:07 -07:00
|
|
|
DotenvLoad(bool),
|
2021-04-24 18:29:58 -07:00
|
|
|
Export(bool),
|
|
|
|
PositionalArguments(bool),
|
|
|
|
Shell(Shell<'src>),
|
2019-11-10 23:17:47 -08:00
|
|
|
}
|
|
|
|
|
2021-11-17 00:07:48 -08:00
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize)]
|
2019-11-10 23:17:47 -08:00
|
|
|
pub(crate) struct Shell<'src> {
|
|
|
|
pub(crate) arguments: Vec<StringLiteral<'src>>,
|
2021-11-17 00:07:48 -08:00
|
|
|
pub(crate) command: StringLiteral<'src>,
|
2019-11-10 23:17:47 -08:00
|
|
|
}
|
2021-06-08 01:01:27 -07:00
|
|
|
|
|
|
|
impl<'src> Display for Setting<'src> {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
|
|
|
|
match self {
|
2021-09-16 07:51:45 -07:00
|
|
|
Setting::DotenvLoad(value) | Setting::Export(value) | Setting::PositionalArguments(value) => {
|
|
|
|
write!(f, "{}", value)
|
|
|
|
}
|
2021-06-08 01:01:27 -07:00
|
|
|
Setting::Shell(shell) => write!(f, "{}", shell),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'src> Display for Shell<'src> {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
|
|
|
|
write!(f, "[{}", self.command)?;
|
|
|
|
|
|
|
|
for argument in &self.arguments {
|
|
|
|
write!(f, ", {}", argument)?;
|
|
|
|
}
|
|
|
|
|
|
|
|
write!(f, "]")
|
|
|
|
}
|
|
|
|
}
|