|
1 | 1 | use crate::config::{self, Config, project::Project, settings::Settings}; |
2 | 2 | use crate::errors::AppError; |
3 | 3 | use crate::ws::github; |
4 | | -use clap::builder::PossibleValue; |
5 | 4 | use git2::Repository; |
6 | 5 | use std::collections::BTreeMap; |
7 | 6 | use std::env; |
8 | 7 | use std::fs; |
9 | 8 | use std::iter::Iterator; |
10 | 9 | use std::path::{Path, PathBuf}; |
11 | 10 |
|
12 | | -#[derive(Copy, Clone)] |
13 | | -pub enum ProjectState { |
14 | | - Active, |
15 | | - Archived, |
16 | | - Both, |
17 | | -} |
18 | | - |
19 | | -impl clap::ValueEnum for ProjectState { |
20 | | - fn value_variants<'a>() -> &'a [Self] { |
21 | | - &[Self::Active, Self::Archived, Self::Both] |
22 | | - } |
23 | | - |
24 | | - fn to_possible_value(&self) -> Option<PossibleValue> { |
25 | | - match self { |
26 | | - Self::Active => Some(PossibleValue::new("active")), |
27 | | - Self::Archived => Some(PossibleValue::new("archived")), |
28 | | - Self::Both => Some(PossibleValue::new("both")), |
29 | | - } |
30 | | - } |
31 | | -} |
32 | | - |
33 | | -impl std::str::FromStr for ProjectState { |
34 | | - type Err = AppError; |
35 | | - |
36 | | - fn from_str(s: &str) -> Result<Self, Self::Err> { |
37 | | - match s { |
38 | | - "active" => Ok(Self::Active), |
39 | | - "archived" => Ok(Self::Archived), |
40 | | - "both" => Ok(Self::Both), |
41 | | - _ => Err(AppError::InternalError("invalid value for ProjectState")), // TODO should this be unreachable?, |
42 | | - } |
43 | | - } |
44 | | -} |
45 | | - |
46 | 11 | pub fn setup(workspace_dir: &str) -> Result<(), AppError> { |
47 | 12 | let path = PathBuf::from(workspace_dir); |
48 | 13 | let maybe_path = if path.exists() { |
|
0 commit comments