mirror of
https://github.com/SkyfallWasTaken/dinopkg.git
synced 2025-05-01 01:09:29 +00:00
Validate licenses in init
This commit is contained in:
parent
b5c4759c98
commit
6a4a73426a
3 changed files with 17 additions and 0 deletions
|
@ -24,3 +24,4 @@ maplit = "1.0.2"
|
|||
serde_json = "1.0.120"
|
||||
syntect = "5.2.0"
|
||||
validate_package_name = { path = "../validate_package_name" }
|
||||
spdx = "0.10.6"
|
||||
|
|
|
@ -84,6 +84,12 @@ pub async fn init() -> Result<()> {
|
|||
.interact_text()?;
|
||||
let license: String = Input::with_theme(&ColorfulTheme::default())
|
||||
.with_prompt("License")
|
||||
.validate_with(|input: &String| {
|
||||
spdx::Expression::parse(input).map_or_else(
|
||||
|err| Err(format!("license is invalid:\n{}", err.to_string())),
|
||||
|_| Ok(()),
|
||||
)
|
||||
})
|
||||
.default("MIT".into())
|
||||
.interact_text()?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue