From a3986bc476332278d4fd4e7204ecd83e510aa193 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Mon, 31 Aug 2026 08:57:56 -0400 Subject: [PATCH 1/8] begin prompting for license --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/config.rs | 22 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fa23687..64333bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,6 +1071,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "spdx", "strum", "strum_macros", "tempfile", @@ -1445,6 +1446,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "spdx" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081670c233dfbed55690cc0cd38424e0e24ac1b2673d0b408b3f7b684738dfa9" +dependencies = [ + "smallvec", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/Cargo.toml b/Cargo.toml index dd042b3..8c2f494 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ open = "5.3.3" reqwest = { version = "0.12.20", features = ["blocking"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" +spdx = "0.13.5" strum = "0.27.1" strum_macros = "0.27.1" tempfile = "3.20.0" diff --git a/src/config.rs b/src/config.rs index 301a275..e33fbbe 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,7 @@ use std::error::Error; use std::fs::File; use std::io::BufWriter; +use std::option; use std::str::FromStr; use std::{ffi::OsString, fs}; @@ -121,6 +122,7 @@ pub struct OsedaConfig { pub color: String, // description must not be empty for check/deploy pub description: String, + pub license: String, } pub fn prompt_for_title() -> Result> { @@ -169,6 +171,8 @@ pub fn create_conf(options: InitOptions) -> Result> let user_name = github::get_config_from_user_git("user.name") .ok_or("Could not get github username. Please ensure you are signed into github")?; + let license = prompt_for_license()?; + Ok(OsedaConfig { title: title.trim().to_owned(), author: user_name, @@ -178,11 +182,23 @@ pub fn create_conf(options: InitOptions) -> Result> .collect(), last_updated: get_time(), color: color.into_hex(), + license: license, // start them with empty description description: String::new(), }) } +fn prompt_for_license() -> Result>{ + let options = spdx::identifiers::LICENSES.iter().map(|l| l.name).collect(); + + let selected_license = inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; + + println!("Selected License: {}", selected_license); + + Ok(selected_license.to_string()) + +} + /// Prompts user for categories associated with their Oseda project /// /// # Returns @@ -195,7 +211,7 @@ fn prompt_for_tags() -> Result, Box> { inquire::MultiSelect::new("Select categories (type to search):", options.clone()) .prompt()?; - println!("You selected:"); + println!("Selected Tags:"); for tags in selected_tags.iter() { println!("- {:?}", tags); } @@ -297,6 +313,7 @@ mod test { author: "JaneDoe".to_string(), tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), + license: "MIT".to_string(), color: Color::Black.into_hex(), description: String::from("Test Description"), }; @@ -315,6 +332,7 @@ mod test { author: "JaneDoe".to_string(), tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), + license: "MIT".to_string(), color: Color::Black.into_hex(), description: String::from("Test Description"), }; @@ -333,6 +351,7 @@ mod test { author: "JaneDoe".to_string(), tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), + license: "MIT".to_string(), color: Color::Black.into_hex(), description: String::new(), }; @@ -354,6 +373,7 @@ mod test { tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), + license: "MIT".to_string(), description: String::from("Test Description"), }; From 5da44d532553b56f73d6ea91fcb663a65cacfafd Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Mon, 31 Aug 2026 10:39:38 -0400 Subject: [PATCH 2/8] filter for only OSI licenses + NewType --- src/config.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index e33fbbe..3ace92e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::fs::File; use std::io::BufWriter; -use std::option; +use std::{fmt, option}; use std::str::FromStr; use std::{ffi::OsString, fs}; @@ -188,15 +188,34 @@ pub fn create_conf(options: InitOptions) -> Result> }) } -fn prompt_for_license() -> Result>{ - let options = spdx::identifiers::LICENSES.iter().map(|l| l.name).collect(); - let selected_license = inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; +// OsedaLicense shall hold a reference to a spdx license +// I just copied this lifetime everywhere and hoping it will be fine +struct OsedaLicense<'a>(&'a spdx::License); + +impl<'a> fmt::Display for OsedaLicense<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0.name) + } +} + +fn prompt_for_license() -> Result> { + + let options = spdx::identifiers::LICENSES + .into_iter() + .filter(|l| match l.flags { + spdx::flags::IS_OSI_APPROVED => true, + _ => false, + }) + .map(|license| OsedaLicense(license)) + .collect(); + + let selected_license = + inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; println!("Selected License: {}", selected_license); Ok(selected_license.to_string()) - } /// Prompts user for categories associated with their Oseda project From 53f3c66d2340e7f002768be61178e55c5add15e2 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Tue, 1 Sep 2026 09:38:44 -0400 Subject: [PATCH 3/8] roll my own license enum instead --- Cargo.lock | 10 ------- Cargo.toml | 1 - src/config.rs | 30 ++++++++++++++++++-- src/lib.rs | 1 + src/license.rs | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 src/license.rs diff --git a/Cargo.lock b/Cargo.lock index 64333bf..fa23687 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,7 +1071,6 @@ dependencies = [ "reqwest", "serde", "serde_json", - "spdx", "strum", "strum_macros", "tempfile", @@ -1446,15 +1445,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spdx" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081670c233dfbed55690cc0cd38424e0e24ac1b2673d0b408b3f7b684738dfa9" -dependencies = [ - "smallvec", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/Cargo.toml b/Cargo.toml index 8c2f494..dd042b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ open = "5.3.3" reqwest = { version = "0.12.20", features = ["blocking"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" -spdx = "0.13.5" strum = "0.27.1" strum_macros = "0.27.1" tempfile = "3.20.0" diff --git a/src/config.rs b/src/config.rs index 3ace92e..a419efa 100644 --- a/src/config.rs +++ b/src/config.rs @@ -173,6 +173,7 @@ pub fn create_conf(options: InitOptions) -> Result> let license = prompt_for_license()?; + Ok(OsedaConfig { title: title.trim().to_owned(), author: user_name, @@ -191,6 +192,7 @@ pub fn create_conf(options: InitOptions) -> Result> // OsedaLicense shall hold a reference to a spdx license // I just copied this lifetime everywhere and hoping it will be fine +#[derive(Debug)] struct OsedaLicense<'a>(&'a spdx::License); impl<'a> fmt::Display for OsedaLicense<'a> { @@ -199,9 +201,22 @@ impl<'a> fmt::Display for OsedaLicense<'a> { } } + +const POPULAR_LICENSES: &[&str] = &[ + "MIT", + "Apache-2.0", + "GPL-3.0-only", + "GPL-3.0-or-later", + "BSD-3-Clause", + "BSD-2-Clause", + "MPL-2.0", + "AGPL-3.0-only", + "CC0-1.0", +]; + fn prompt_for_license() -> Result> { - let options = spdx::identifiers::LICENSES + let mut options: Vec = spdx::identifiers::LICENSES .into_iter() .filter(|l| match l.flags { spdx::flags::IS_OSI_APPROVED => true, @@ -210,6 +225,17 @@ fn prompt_for_license() -> Result> { .map(|license| OsedaLicense(license)) .collect(); + + // all this junk to say put the most popular ones on top + // and all the type shenanigans associated + options.sort_by_key(|license| { + let id = license.0.name; + let priority = POPULAR_LICENSES.iter().position(|&p| p == id); + (priority.unwrap_or(usize::MAX), id) + }); + + println!("options: {options:?}"); + let selected_license = inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; @@ -247,7 +273,7 @@ fn prompt_for_color() -> Result> { ) .prompt()?; - println!("You selected: {:?}", selected_color); + println!("Selected Color: {:?}", selected_color); Ok(selected_color) } diff --git a/src/lib.rs b/src/lib.rs index ddb94b3..30141aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ pub mod net; pub mod puppeteer; pub mod tags; pub mod template; +pub mod license; /// Oseda Project scafolding CLI #[derive(Parser)] diff --git a/src/license.rs b/src/license.rs new file mode 100644 index 0000000..742de96 --- /dev/null +++ b/src/license.rs @@ -0,0 +1,74 @@ +/// OSI approved license categorized as (popular / strong community) +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum License { + /// Apache 2.0 + Apache2_0, + /// Common Development and Distribution License 1.0 + Cddl1_0, + /// Eclipse Public License 2.0 + Epl2_0, + /// GNU General Public License 2 + Gpl2_0, + /// GNU General Public License 3 + Gpl3_0, + /// GNU Lesser General Public License version 2.1 + Lgpl2_1, + /// GNU Lesser General Public License version 3 + Lgpl3_0, + /// GNU Library General Public License version 2 + Lgpl2_0, + /// Mozilla Public License 2.0 + Mpl2_0, + /// 2-Clause BSD + Bsd2Clause, + /// 3-Clause BSD + Bsd3Clause, + /// MIT + Mit, +} + +impl License { + /// Get the full name of license + pub const fn name(&self) -> &'static str { + match self { + Self::Apache2_0 => "Apache License, Version 2.0", + Self::Cddl1_0 => "Common Development and Distribution License 1.0", + Self::Epl2_0 => "Eclipse Public License version 2.0", + Self::Gpl2_0 => "GNU General Public License version 2", + Self::Gpl3_0 => "GNU General Public License version 3", + Self::Lgpl2_1 => "GNU Lesser General Public License version 2.1", + Self::Lgpl3_0 => "GNU Lesser General Public License version 3", + Self::Lgpl2_0 => "GNU Library General Public License version 2", + Self::Mpl2_0 => "Mozilla Public License 2.0", + Self::Bsd2Clause => "The 2-Clause BSD License", + Self::Bsd3Clause => "The 3-Clause BSD License", + Self::Mit => "The MIT License", + } + } + + /// Get the SPDX id associated with a license. + /// Internally, `oseda check` will recognize one of these strings + pub const fn spdx_id(&self) -> &'static str { + match self { + Self::Apache2_0 => "Apache-2.0", + Self::Cddl1_0 => "CDDL-1.0", + Self::Epl2_0 => "EPL-2.0", + Self::Gpl2_0 => "GPL-2.0", + Self::Gpl3_0 => "GPL-3.0", + Self::Lgpl2_1 => "LGPL-2.1", + Self::Lgpl3_0 => "LGPL-3.0", + Self::Lgpl2_0 => "LGPL-2.0", + Self::Mpl2_0 => "MPL-2.0", + Self::Bsd2Clause => "BSD-2-Clause", + Self::Bsd3Clause => "BSD-3-Clause", + Self::Mit => "MIT", + } + } + +} + +impl std::fmt::Display for License{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.spdx_id()) + } +} \ No newline at end of file From 315a833d8656215c19cdee8671407898422429ba Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Tue, 1 Sep 2026 10:14:39 -0400 Subject: [PATCH 4/8] update license implementation with serde and strum compatibility --- src/config.rs | 66 +++++++++++++++++--------------------------------- src/license.rs | 52 ++++++++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 61 deletions(-) diff --git a/src/config.rs b/src/config.rs index a419efa..e0cc4b1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,6 +14,7 @@ use crate::cmd::check::OsedaCheckError; use crate::cmd::init::InitOptions; use crate::color::Color; use crate::github; +use crate::license::License; use crate::tags::DefinedTag; pub fn read_config_file>( @@ -122,7 +123,7 @@ pub struct OsedaConfig { pub color: String, // description must not be empty for check/deploy pub description: String, - pub license: String, + pub license: License, } pub fn prompt_for_title() -> Result> { @@ -190,58 +191,35 @@ pub fn create_conf(options: InitOptions) -> Result> } -// OsedaLicense shall hold a reference to a spdx license -// I just copied this lifetime everywhere and hoping it will be fine -#[derive(Debug)] -struct OsedaLicense<'a>(&'a spdx::License); - -impl<'a> fmt::Display for OsedaLicense<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0.name) - } -} - - -const POPULAR_LICENSES: &[&str] = &[ - "MIT", - "Apache-2.0", - "GPL-3.0-only", - "GPL-3.0-or-later", - "BSD-3-Clause", - "BSD-2-Clause", - "MPL-2.0", - "AGPL-3.0-only", - "CC0-1.0", -]; fn prompt_for_license() -> Result> { - let mut options: Vec = spdx::identifiers::LICENSES - .into_iter() - .filter(|l| match l.flags { - spdx::flags::IS_OSI_APPROVED => true, - _ => false, - }) - .map(|license| OsedaLicense(license)) - .collect(); + // let mut options: Vec = spdx::identifiers::LICENSES + // .into_iter() + // .filter(|l| match l.flags { + // spdx::flags::IS_OSI_APPROVED => true, + // _ => false, + // }) + // .map(|license| OsedaLicense(license)) + // .collect(); - // all this junk to say put the most popular ones on top - // and all the type shenanigans associated - options.sort_by_key(|license| { - let id = license.0.name; - let priority = POPULAR_LICENSES.iter().position(|&p| p == id); - (priority.unwrap_or(usize::MAX), id) - }); + // // all this junk to say put the most popular ones on top + // // and all the type shenanigans associated + // options.sort_by_key(|license| { + // let id = license.0.name; + // let priority = POPULAR_LICENSES.iter().position(|&p| p == id); + // (priority.unwrap_or(usize::MAX), id) + // }); - println!("options: {options:?}"); + // println!("options: {options:?}"); - let selected_license = - inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; + // let selected_license = + // inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; - println!("Selected License: {}", selected_license); + // println!("Selected License: {}", selected_license); - Ok(selected_license.to_string()) + // Ok(selected_license.to_string()) } /// Prompts user for categories associated with their Oseda project diff --git a/src/license.rs b/src/license.rs index 742de96..acb4b51 100644 --- a/src/license.rs +++ b/src/license.rs @@ -1,34 +1,43 @@ -/// OSI approved license categorized as (popular / strong community) -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +use serde::{Deserialize, Serialize}; +use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr}; + +/// OSI approved license categorized as (popular / strong community) +#[derive(Debug, Clone, PartialEq, Eq, Hash, EnumIter, IntoStaticStr, EnumString, Serialize, Deserialize)] +#[serde(into = "&'static str", try_from = "String")] pub enum License { - /// Apache 2.0 + // strum serialize is compatible with serde trait here + // this will basically allow a complex internal license representation + // but with ease of de/serialization with just the spdx id + #[strum(serialize = "Apache-2.0")] Apache2_0, - /// Common Development and Distribution License 1.0 + #[strum(serialize = "CDDL-1.0")] Cddl1_0, - /// Eclipse Public License 2.0 + #[strum(serialize = "EPL-2.0")] Epl2_0, - /// GNU General Public License 2 + #[strum(serialize = "GPL-2.0")] Gpl2_0, - /// GNU General Public License 3 + #[strum(serialize = "GPL-3.0")] Gpl3_0, - /// GNU Lesser General Public License version 2.1 + #[strum(serialize = "LGPL-2.1")] Lgpl2_1, - /// GNU Lesser General Public License version 3 + #[strum(serialize = "LGPL-3.0")] Lgpl3_0, - /// GNU Library General Public License version 2 + #[strum(serialize = "LGPL-2.0")] Lgpl2_0, - /// Mozilla Public License 2.0 + #[strum(serialize = "MPL-2.0")] Mpl2_0, - /// 2-Clause BSD + #[strum(serialize = "BSD-2-Clause")] Bsd2Clause, - /// 3-Clause BSD + #[strum(serialize = "BSD-3-Clause")] Bsd3Clause, - /// MIT + #[strum(serialize = "MIT")] Mit, } + + impl License { - /// Get the full name of license + /// Get the full name of license. I'm not sure if this really ever be useful, but i figured its best to include it pub const fn name(&self) -> &'static str { match self { Self::Apache2_0 => "Apache License, Version 2.0", @@ -64,11 +73,20 @@ impl License { Self::Mit => "MIT", } } - } + impl std::fmt::Display for License{ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.spdx_id()) } -} \ No newline at end of file +} + +// useful for oseda check attempting to parse a license spdx id +impl TryFrom for License { + type Error = strum::ParseError; + + fn try_from(s: String) -> Result { + s.parse() + } +} From 78fe7522205a43b9d5f0c5244f975d25c85f2f4b Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Tue, 1 Sep 2026 12:01:59 -0400 Subject: [PATCH 5/8] re-write license again, but with only support for popular/community licenses --- src/config.rs | 44 ++++++++++++++------------------------------ src/license.rs | 10 +++++----- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/config.rs b/src/config.rs index e0cc4b1..bb2c2ec 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,7 +13,7 @@ use strum::IntoEnumIterator; use crate::cmd::check::OsedaCheckError; use crate::cmd::init::InitOptions; use crate::color::Color; -use crate::github; +use crate::{github, license}; use crate::license::License; use crate::tags::DefinedTag; @@ -192,34 +192,18 @@ pub fn create_conf(options: InitOptions) -> Result> -fn prompt_for_license() -> Result> { - - // let mut options: Vec = spdx::identifiers::LICENSES - // .into_iter() - // .filter(|l| match l.flags { - // spdx::flags::IS_OSI_APPROVED => true, - // _ => false, - // }) - // .map(|license| OsedaLicense(license)) - // .collect(); +fn prompt_for_license() -> Result> { + let options: Vec = license::License::iter() + .map(|lic: License| license::License::spdx_id(&lic)) + .map(|lic_str| lic_str.into()) + .collect(); + let selected_license = + inquire::Select::new("Select license: (type to search):", options) + .prompt()?; - // // all this junk to say put the most popular ones on top - // // and all the type shenanigans associated - // options.sort_by_key(|license| { - // let id = license.0.name; - // let priority = POPULAR_LICENSES.iter().position(|&p| p == id); - // (priority.unwrap_or(usize::MAX), id) - // }); - - // println!("options: {options:?}"); - - // let selected_license = - // inquire::Select::new("Select OSI approved license (type to search):", options).prompt()?; - - // println!("Selected License: {}", selected_license); + Ok(License::try_from(selected_license)?) - // Ok(selected_license.to_string()) } /// Prompts user for categories associated with their Oseda project @@ -336,7 +320,7 @@ mod test { author: "JaneDoe".to_string(), tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), - license: "MIT".to_string(), + license: License::Apache2_0, color: Color::Black.into_hex(), description: String::from("Test Description"), }; @@ -355,7 +339,7 @@ mod test { author: "JaneDoe".to_string(), tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), - license: "MIT".to_string(), + license: License::Mit, color: Color::Black.into_hex(), description: String::from("Test Description"), }; @@ -374,7 +358,7 @@ mod test { author: "JaneDoe".to_string(), tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), - license: "MIT".to_string(), + license: License::Bsd3Clause, color: Color::Black.into_hex(), description: String::new(), }; @@ -396,7 +380,7 @@ mod test { tags: vec![DefinedTag::ComputerScience.to_string()], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), - license: "MIT".to_string(), + license: License::Gpl3_0, description: String::from("Test Description"), }; diff --git a/src/license.rs b/src/license.rs index acb4b51..b00454b 100644 --- a/src/license.rs +++ b/src/license.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; -use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr}; +use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr, }; /// OSI approved license categorized as (popular / strong community) -#[derive(Debug, Clone, PartialEq, Eq, Hash, EnumIter, IntoStaticStr, EnumString, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, EnumIter,IntoStaticStr, EnumString, Serialize, Deserialize)] #[serde(into = "&'static str", try_from = "String")] pub enum License { // strum serialize is compatible with serde trait here @@ -10,6 +10,8 @@ pub enum License { // but with ease of de/serialization with just the spdx id #[strum(serialize = "Apache-2.0")] Apache2_0, + #[strum(serialize = "MIT")] + Mit, #[strum(serialize = "CDDL-1.0")] Cddl1_0, #[strum(serialize = "EPL-2.0")] @@ -30,15 +32,13 @@ pub enum License { Bsd2Clause, #[strum(serialize = "BSD-3-Clause")] Bsd3Clause, - #[strum(serialize = "MIT")] - Mit, } impl License { /// Get the full name of license. I'm not sure if this really ever be useful, but i figured its best to include it - pub const fn name(&self) -> &'static str { + pub const fn name(&self) -> &str { match self { Self::Apache2_0 => "Apache License, Version 2.0", Self::Cddl1_0 => "Common Development and Distribution License 1.0", From bb3da58b37490ac95811118ce20953366d85d3a4 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Tue, 1 Sep 2026 12:09:52 -0400 Subject: [PATCH 6/8] reorder struct for more popular ones first --- src/license.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/license.rs b/src/license.rs index b00454b..dfcc3e0 100644 --- a/src/license.rs +++ b/src/license.rs @@ -41,6 +41,7 @@ impl License { pub const fn name(&self) -> &str { match self { Self::Apache2_0 => "Apache License, Version 2.0", + Self::Mit => "The MIT License", Self::Cddl1_0 => "Common Development and Distribution License 1.0", Self::Epl2_0 => "Eclipse Public License version 2.0", Self::Gpl2_0 => "GNU General Public License version 2", @@ -51,7 +52,6 @@ impl License { Self::Mpl2_0 => "Mozilla Public License 2.0", Self::Bsd2Clause => "The 2-Clause BSD License", Self::Bsd3Clause => "The 3-Clause BSD License", - Self::Mit => "The MIT License", } } @@ -60,6 +60,7 @@ impl License { pub const fn spdx_id(&self) -> &'static str { match self { Self::Apache2_0 => "Apache-2.0", + Self::Mit => "MIT", Self::Cddl1_0 => "CDDL-1.0", Self::Epl2_0 => "EPL-2.0", Self::Gpl2_0 => "GPL-2.0", @@ -70,7 +71,6 @@ impl License { Self::Mpl2_0 => "MPL-2.0", Self::Bsd2Clause => "BSD-2-Clause", Self::Bsd3Clause => "BSD-3-Clause", - Self::Mit => "MIT", } } } From 0fa38e304043e9acd88f77e2c102d9047b62cabd Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Tue, 1 Sep 2026 18:39:47 -0400 Subject: [PATCH 7/8] fmt --- src/cmd/check.rs | 2 -- src/config.rs | 13 ++++--------- src/lib.rs | 2 +- src/license.rs | 13 ++++++------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/cmd/check.rs b/src/cmd/check.rs index 3f2193e..532fb89 100644 --- a/src/cmd/check.rs +++ b/src/cmd/check.rs @@ -86,8 +86,6 @@ pub enum OsedaProjectStatus { /// * `OsedaProjectStatus::DeployReady` if the project passes all checks /// * `OsedaProjectStatus::NotDeploymentReady(err)` if something fails that is commonly seen fn verify_project(port_num: u16) -> OsedaProjectStatus { - // TODO: document me -> assumes working directory is the project folder - let _conf = match config::read_and_validate_config() { Ok(conf) => conf, Err(err) => return OsedaProjectStatus::NotDeploymentReady(err), diff --git a/src/config.rs b/src/config.rs index bb2c2ec..1e4dbca 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,9 +1,9 @@ use std::error::Error; use std::fs::File; use std::io::BufWriter; -use std::{fmt, option}; use std::str::FromStr; use std::{ffi::OsString, fs}; +use std::{fmt, option}; use chrono::{DateTime, Utc}; use inquire::validator::Validation; @@ -13,9 +13,9 @@ use strum::IntoEnumIterator; use crate::cmd::check::OsedaCheckError; use crate::cmd::init::InitOptions; use crate::color::Color; -use crate::{github, license}; use crate::license::License; use crate::tags::DefinedTag; +use crate::{github, license}; pub fn read_config_file>( path: P, @@ -174,7 +174,6 @@ pub fn create_conf(options: InitOptions) -> Result> let license = prompt_for_license()?; - Ok(OsedaConfig { title: title.trim().to_owned(), author: user_name, @@ -190,20 +189,16 @@ pub fn create_conf(options: InitOptions) -> Result> }) } - - fn prompt_for_license() -> Result> { let options: Vec = license::License::iter() .map(|lic: License| license::License::spdx_id(&lic)) .map(|lic_str| lic_str.into()) .collect(); - let selected_license = - inquire::Select::new("Select license: (type to search):", options) - .prompt()?; + let selected_license = + inquire::Select::new("Select license: (type to search):", options).prompt()?; Ok(License::try_from(selected_license)?) - } /// Prompts user for categories associated with their Oseda project diff --git a/src/lib.rs b/src/lib.rs index 30141aa..2d616c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,11 +4,11 @@ pub mod cmd; pub mod color; pub mod config; pub mod github; +pub mod license; pub mod net; pub mod puppeteer; pub mod tags; pub mod template; -pub mod license; /// Oseda Project scafolding CLI #[derive(Parser)] diff --git a/src/license.rs b/src/license.rs index dfcc3e0..04df5fa 100644 --- a/src/license.rs +++ b/src/license.rs @@ -1,8 +1,10 @@ use serde::{Deserialize, Serialize}; -use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr, }; +use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr}; -/// OSI approved license categorized as (popular / strong community) -#[derive(Debug, Clone, PartialEq, Eq, Hash, EnumIter,IntoStaticStr, EnumString, Serialize, Deserialize)] +/// OSI approved license categorized as (popular / strong community) +#[derive( + Debug, Clone, PartialEq, Eq, Hash, EnumIter, IntoStaticStr, EnumString, Serialize, Deserialize, +)] #[serde(into = "&'static str", try_from = "String")] pub enum License { // strum serialize is compatible with serde trait here @@ -34,8 +36,6 @@ pub enum License { Bsd3Clause, } - - impl License { /// Get the full name of license. I'm not sure if this really ever be useful, but i figured its best to include it pub const fn name(&self) -> &str { @@ -75,8 +75,7 @@ impl License { } } - -impl std::fmt::Display for License{ +impl std::fmt::Display for License { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.spdx_id()) } From 2c6f88958a78601289bb5cc1c179f7a96749a0b3 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Tue, 1 Sep 2026 18:40:41 -0400 Subject: [PATCH 8/8] clippy --- src/config.rs | 3 +-- src/license.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 1e4dbca..a528d62 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,7 +3,6 @@ use std::fs::File; use std::io::BufWriter; use std::str::FromStr; use std::{ffi::OsString, fs}; -use std::{fmt, option}; use chrono::{DateTime, Utc}; use inquire::validator::Validation; @@ -183,7 +182,7 @@ pub fn create_conf(options: InitOptions) -> Result> .collect(), last_updated: get_time(), color: color.into_hex(), - license: license, + license, // start them with empty description description: String::new(), }) diff --git a/src/license.rs b/src/license.rs index 04df5fa..32220e0 100644 --- a/src/license.rs +++ b/src/license.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr}; +use strum_macros::{EnumIter, EnumString, IntoStaticStr}; /// OSI approved license categorized as (popular / strong community) #[derive(