1use crate::error::{Error, Result};
2use std::env;
3
4#[derive(PartialEq, Debug)]
5pub enum Update {
6 Wip,
7 Overwrite,
8}
9
10impl Default for Update {
11 fn default() -> Self {
12 Update::Wip
13 }
14}
15
16impl Update {
17 pub fn env() -> Result<Self> {
18 let var = match env::var_os("TRYBUILD") {
19 Some(var) => var,
20 None => return Ok(Update::default()),
21 };
22
23 match var.as_os_str().to_str() {
24 Some("wip") => Ok(Update::Wip),
25 Some("overwrite") => Ok(Update::Overwrite),
26 _ => Err(Error::UpdateVar(var)),
27 }
28 }
29}
30