~prma/ddd

42522da64347537754deef86513b7a5546670bdc — Perma Alesheikh 5 months ago 3417dfc
add check for zero articles

Signed-off-by: Perma Alesheikh <me@prma.dev>
1 files changed, 14 insertions(+), 9 deletions(-)

M src/bin/ddd/main.rs
M src/bin/ddd/main.rs => src/bin/ddd/main.rs +14 -9
@@ 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),