just/src/setting.rs

41 lines
978 B
Rust
Raw Normal View History

use crate::common::*;
2021-06-08 01:01:27 -07:00
#[derive(Debug, Clone)]
pub(crate) enum Setting<'src> {
DotenvLoad(bool),
Export(bool),
PositionalArguments(bool),
Shell(Shell<'src>),
2022-01-18 11:02:15 -08:00
WindowsPowerShell(bool),
}
2021-11-17 00:07:48 -08:00
#[derive(Debug, Clone, PartialEq, Serialize)]
pub(crate) struct Shell<'src> {
pub(crate) arguments: Vec<StringLiteral<'src>>,
2021-11-17 00:07:48 -08:00
pub(crate) command: StringLiteral<'src>,
}
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 {
2022-01-18 11:02:15 -08:00
Setting::DotenvLoad(value)
| Setting::Export(value)
| Setting::PositionalArguments(value)
| Setting::WindowsPowerShell(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, "]")
}
}