Skip to main content

duvet/
lib.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4use clap::Parser;
5use std::sync::Arc;
6
7mod annotation;
8mod comment;
9mod config;
10mod extract;
11mod init;
12mod project;
13mod reference;
14mod report;
15mod source;
16mod specification;
17mod target;
18mod text;
19
20pub use duvet_core::{diagnostic::Error, Result};
21
22#[allow(clippy::large_enum_variant)]
23#[derive(Debug, Parser)]
24pub enum Arguments {
25    /// Initializes a duvet project
26    Init(init::Init),
27    /// Extracts requirements out of a specification
28    Extract(extract::Extract),
29    /// Generates reports for the project
30    Report(report::Report),
31}
32
33#[duvet_core::query(cache)]
34pub async fn arguments() -> Arc<Arguments> {
35    Arc::new(Arguments::parse())
36}
37
38impl Arguments {
39    pub async fn exec(&self) -> Result {
40        match self {
41            Self::Init(args) => args.exec().await,
42            Self::Extract(args) => args.exec().await,
43            Self::Report(args) => args.exec().await,
44        }
45    }
46}
47
48pub async fn run() -> Result {
49    arguments().await.exec().await?;
50    Ok(())
51}