@@ 7,7 7,7 @@ use std::env;
use arguments::{Args, Commands, NewCommands};
use clap::{CommandFactory, Parser};
-use color_eyre::eyre::{Error, OptionExt, Result};
+use color_eyre::eyre::{eyre, Error, OptionExt, Result};
use tracing::{debug, level_filters::LevelFilter};
use tracing_error::ErrorLayer;
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
@@ 43,14 43,19 @@ fn main() -> Result<()> {
word,
meaning,
group,
- } => commands::new_noun(
- time::OffsetDateTime::now_utc().unix_timestamp_nanos(),
- word,
- meaning,
- articles,
- group,
- &storage,
- ),
+ } => {
+ if articles.is_empty() {
+ return Err(eyre!("You should enter at least one article."));
+ }
+ commands::new_noun(
+ time::OffsetDateTime::now_utc().unix_timestamp_nanos(),
+ word,
+ meaning,
+ articles,
+ group,
+ &storage,
+ )
+ }
},
Commands::List(list_commands) => match list_commands {
arguments::ListCommands::Nouns => commands::list_nouns(&storage, &storage),