diff --git a/scripts/test-init.sh b/scripts/test-init.sh index 66f9231..dd315fb 100755 --- a/scripts/test-init.sh +++ b/scripts/test-init.sh @@ -11,7 +11,6 @@ set -e cp target/release/oseda test - cd test diff --git a/src/config.rs b/src/config.rs index 74c4da9..1297111 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use inquire::validator::Validation; use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; -use crate::categories::Category; +use crate::tags::Tag; use crate::cmd::check::OsedaCheckError; use crate::color::Color; use crate::github; @@ -101,7 +101,7 @@ pub fn validate_config( pub struct OsedaConfig { pub title: String, pub author: String, - pub category: Vec, + pub tags: Vec, // effectively mutable. Will get updated on each deployment pub last_updated: DateTime, pub color: String, @@ -132,7 +132,7 @@ pub fn create_conf() -> Result> { title = title.replace(" ", "-"); - let categories = get_categories()?; + let tags = get_tags()?; let color = get_color()?; let user_name = github::get_config_from_user_git("user.name") @@ -141,7 +141,7 @@ pub fn create_conf() -> Result> { Ok(OsedaConfig { title: title.trim().to_owned(), author: user_name, - category: categories, + tags, last_updated: get_time(), color: color.into_hex(), }) @@ -150,21 +150,23 @@ pub fn create_conf() -> Result> { /// Prompts user for categories associated with their Oseda project /// /// # Returns -/// * `Ok(Vec)` with selected categories +/// * `Ok(Vec)` with selected categories /// * `Err` if the prompting went wrong somewhere -fn get_categories() -> Result, Box> { - let options: Vec = Category::iter().collect(); +fn get_tags() -> Result, Box> { + let options: Vec = Tag::iter().collect(); - let selected_categories = - inquire::MultiSelect::new("Select categories (type to search):", options.clone()) + println!("Select tags that match your course's meaning and purpose."); + println!("(You can always add custom tags later!)"); + let selected_tags = + inquire::MultiSelect::new("Select tags (type to search):", options.clone()) .prompt()?; println!("You selected:"); - for category in selected_categories.iter() { - println!("- {:?}", category); + for tag in selected_tags.iter() { + println!("- {:?}", tag); } - Ok(selected_categories) + Ok(selected_tags) } fn get_color() -> Result> { @@ -236,7 +238,7 @@ mod test { { "title": "TestableRust", "author": "JaneDoe", - "category": ["ComputerScience"], + "tags": ["ComputerScience"], "last_updated": "2024-07-10T12:34:56Z" } "# @@ -258,7 +260,7 @@ mod test { let conf = OsedaConfig { title: "my-project".to_string(), author: "JaneDoe".to_string(), - category: vec![Category::ComputerScience], + tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), }; @@ -275,7 +277,7 @@ mod test { let conf = OsedaConfig { title: "my-project".to_string(), author: "JaneDoe".to_string(), - category: vec![Category::ComputerScience], + tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), }; @@ -292,7 +294,7 @@ mod test { let conf = OsedaConfig { title: "correct-name".to_string(), author: "JaneDoe".to_string(), - category: vec![Category::ComputerScience], + tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), }; @@ -311,7 +313,7 @@ mod test { let conf = OsedaConfig { title: "oseda".to_string(), author: "JaneDoe".to_string(), - category: vec![Category::ComputerScience], + tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), }; diff --git a/src/lib.rs b/src/lib.rs index 5bcefa1..4323213 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -pub mod categories; +pub mod tags; pub mod cmd; pub mod color; pub mod config; diff --git a/src/categories.rs b/src/tags.rs similarity index 68% rename from src/categories.rs rename to src/tags.rs index 9f924a0..f2ba701 100644 --- a/src/categories.rs +++ b/src/tags.rs @@ -3,7 +3,7 @@ use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter}; #[derive(Serialize, Deserialize, Debug, Clone, Copy, Display, EnumIter)] -pub enum Category { +pub enum Tag { Aerospace, Business, ComputerScience, @@ -19,10 +19,13 @@ pub enum Category { Politics, Psychology, Science, + // Custom(String), } +// TODO document me +// Custom tags must be added by hand to the oseda-config.json -impl Category { - pub fn to_vec() -> Vec { - Category::iter().collect() +impl Tag { + pub fn to_vec() -> Vec { + Tag::iter().collect() } }