diff --git a/Cargo.lock b/Cargo.lock
index fa23687..541f513 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1059,7 +1059,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "oseda-cli"
-version = "2.7.0"
+version = "3.0.0"
dependencies = [
"chrono",
"clap",
diff --git a/Cargo.toml b/Cargo.toml
index dd042b3..79233ee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ homepage = "https://oseda.net"
repository = "https://github.com/oseda-dev/oseda-cli"
readme = "README.md"
name = "oseda-cli"
-version = "2.7.0"
+version = "3.0.0"
edition = "2021"
[[bin]]
diff --git a/Usage.md b/Usage.md
index 0ed32e1..c9953e7 100644
--- a/Usage.md
+++ b/Usage.md
@@ -39,10 +39,12 @@ Initialize a new Oseda project in the working directory
###### **Options:**
-* `--title
`
-* `--tags `
-* `--color `
-* `--template `
+* `--title ` — Project Title
+* `--tags ` — Project Tags [e.g: ComputerScience,Engineering,...]
+* `--color ` — Project Color [e.g: Red]
+* `--template ` — Project Template Format [HTML | Markdown]
+* `--license ` — OSI License SPDX identifier [e.g: MIT]
+* `--description ` — Project Description
diff --git a/scripts/test-init.sh b/scripts/test-init.sh
index 7f8e5b9..fb5dd8b 100755
--- a/scripts/test-init.sh
+++ b/scripts/test-init.sh
@@ -12,6 +12,12 @@ cd test
pwd
-./oseda init --title ExampleProject --tags economics ComPuterScience --color red --template HTML
+./oseda init \
+ --title ExampleProject \
+ --tags "economics, ComPuterScience" \
+ --color red \
+ --template HTML \
+ --description "This is an example project" \
+ --license "gPl-2.0"
mv oseda ExampleProject
\ No newline at end of file
diff --git a/scripts/update-usage.sh b/scripts/update-usage.sh
new file mode 100755
index 0000000..8fb1d0a
--- /dev/null
+++ b/scripts/update-usage.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+# updates the usage.md file based on clap doc comments
+
+cargo run --bin oseda-usage
\ No newline at end of file
diff --git a/src/cmd/init.rs b/src/cmd/init.rs
index 35e092c..ca03163 100644
--- a/src/cmd/init.rs
+++ b/src/cmd/init.rs
@@ -13,17 +13,32 @@ use crate::{config, template::Template};
/// Options for the `oseda init` command
#[derive(Args, Debug)]
pub struct InitOptions {
- #[arg(long)]
+ // claps 'value_name' does not change the argument name, basically just the value in the help menu,
+ // e.g --template
+
+ /// Project Title
+ #[arg(long, value_name = "TITLE")]
pub title: Option,
- #[arg(long, num_args = 1.., value_delimiter=' ')]
+ /// Project Tags [e.g: ComputerScience,Engineering,...]
+ #[arg(long, value_delimiter = ',', value_name = "TAG1,TAG2,...")]
pub tags: Option>,
- #[arg(long)]
+ /// Project Color [e.g: Red]
+ #[arg(long, value_name = "COLOR")]
pub color: Option,
- #[arg(long)]
+ /// Project Template Format [HTML | Markdown]
+ #[arg(long, value_name = "FORMAT")]
pub template: Option,
+
+ /// OSI License SPDX identifier [e.g: MIT]
+ #[arg(long, value_name = "SPDX_ID")]
+ pub license: Option,
+
+ /// Project Description
+ #[arg(long, value_name = "TEXT")]
+ pub description: Option,
}
// embed all the static markdown template files into binary
diff --git a/src/config.rs b/src/config.rs
index a528d62..c447b73 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -96,7 +96,7 @@ pub fn validate_config(
));
}
- if conf.description.is_empty() {
+ if conf.description.is_empty() || conf.description.eq_ignore_ascii_case(DEFAULT_DESCIPTION) {
return Err(OsedaCheckError::MissingDescription(
"Description is missing or empty. Please update the oseda-config.json".to_owned(),
));
@@ -125,6 +125,9 @@ pub struct OsedaConfig {
pub license: License,
}
+
+const DEFAULT_DESCIPTION: &'static str = "Fill in project description";
+
pub fn prompt_for_title() -> Result> {
let validator = |input: &str| {
if input.chars().count() < 2 {
@@ -155,7 +158,7 @@ pub fn create_conf(options: InitOptions) -> Result>
Some(arg_tags) => {
arg_tags
.iter()
- .map(|arg_tag| DefinedTag::from_str(arg_tag))
+ .map(|arg_tag| DefinedTag::from_str(arg_tag.trim()))
.collect::, _>>()
.map_err(|_| "Invalid tag. Custom Tags may be added to the oseda-config.json after initialization".to_string())?
},
@@ -169,9 +172,26 @@ 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")?;
+ .ok_or("Could not get GitHub username. Please ensure you are signed into github")?;
+
+ let description = match options.description {
+ Some(desc) => desc,
+ None => {
+ DEFAULT_DESCIPTION.to_owned()
+ },
+ };
+
+
+ let license = match options.license {
+ Some(proposed_license) => {
+ License::try_from(proposed_license.clone()).or_else(|_| {
+ eprintln!("Error: Invalid license '{}', please select from the following:", proposed_license);
+ prompt_for_license()
+ })?
+ }
+ None => prompt_for_license()?,
+ };
- let license = prompt_for_license()?;
Ok(OsedaConfig {
title: title.trim().to_owned(),
@@ -183,8 +203,7 @@ pub fn create_conf(options: InitOptions) -> Result>
last_updated: get_time(),
color: color.into_hex(),
license,
- // start them with empty description
- description: String::new(),
+ description
})
}
diff --git a/src/license.rs b/src/license.rs
index 32220e0..0453cf2 100644
--- a/src/license.rs
+++ b/src/license.rs
@@ -10,29 +10,29 @@ pub enum License {
// 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")]
+ #[strum(serialize = "Apache-2.0", ascii_case_insensitive)]
Apache2_0,
- #[strum(serialize = "MIT")]
+ #[strum(serialize = "MIT", ascii_case_insensitive)]
Mit,
- #[strum(serialize = "CDDL-1.0")]
+ #[strum(serialize = "CDDL-1.0", ascii_case_insensitive)]
Cddl1_0,
- #[strum(serialize = "EPL-2.0")]
+ #[strum(serialize = "EPL-2.0", ascii_case_insensitive)]
Epl2_0,
- #[strum(serialize = "GPL-2.0")]
+ #[strum(serialize = "GPL-2.0", ascii_case_insensitive)]
Gpl2_0,
- #[strum(serialize = "GPL-3.0")]
+ #[strum(serialize = "GPL-3.0", ascii_case_insensitive)]
Gpl3_0,
- #[strum(serialize = "LGPL-2.1")]
+ #[strum(serialize = "LGPL-2.1", ascii_case_insensitive)]
Lgpl2_1,
- #[strum(serialize = "LGPL-3.0")]
+ #[strum(serialize = "LGPL-3.0", ascii_case_insensitive)]
Lgpl3_0,
- #[strum(serialize = "LGPL-2.0")]
+ #[strum(serialize = "LGPL-2.0", ascii_case_insensitive)]
Lgpl2_0,
- #[strum(serialize = "MPL-2.0")]
+ #[strum(serialize = "MPL-2.0", ascii_case_insensitive)]
Mpl2_0,
- #[strum(serialize = "BSD-2-Clause")]
+ #[strum(serialize = "BSD-2-Clause", ascii_case_insensitive)]
Bsd2Clause,
- #[strum(serialize = "BSD-3-Clause")]
+ #[strum(serialize = "BSD-3-Clause", ascii_case_insensitive)]
Bsd3Clause,
}