• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polyphony-chat / sonata / #8

21 Jun 2025 07:46PM UTC coverage: 0.0%. Remained the same
#8

push

bitfl0wer
chore: add crate docs

0 of 8 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cli/mod.rs
1
// This Source Code Form is subject to the terms of the Mozilla Public
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4

5
use std::path::PathBuf;
6
use std::sync::OnceLock;
7

8
use clap::Parser;
9

10
use crate::StdResult;
11

12
static CLI_ARGUMENTS: OnceLock<Args> = OnceLock::new();
13

14
#[derive(Debug, clap::Parser)]
15
#[command(name = "sonata")]
16
#[command(version, long_about = None)]
17
pub struct Args {
18
    #[arg(short, long, value_name = "FILE")]
19
    /// Path to a sonata config.toml file. If not specified, will use default values.
20
    pub(crate) config: Option<PathBuf>,
21

22
    #[arg(short = 'v', long, action = clap::ArgAction::Count)]
23
    /// Turn on verbose logging. The default log level is "INFO".
24
    /// Each instance of "v" in "-v" will increase the logging level by one. Logging levels are
25
    /// DEBUG (-v) and TRACE (-vv).
26
    /// "Quiet" settings override "verbose" settings. If set, overrides config value.
27
    pub(crate) verbose: u8,
28
    #[arg(short = 'q', long, action = clap::ArgAction::Count)]
29
    /// Configure "quiet" mode. The default log level is "INFO".
30
    /// Each instance of "q" in "-q" will decrease the logging level by one. Logging levels are
31
    /// WARN (-q), ERROR (-qq) and None (completely silent, except for regular stdout) (-qqq).
32
    /// "Quiet" settings override "verbose" settings. If set, overrides config value.
33
    pub(crate) quiet: u8,
34
}
35

36
impl Args {
37
    pub fn init_global() -> StdResult<&'static Self> {
×
38
        let parsed = Args::try_parse()?;
×
39
        CLI_ARGUMENTS.set(parsed).map_err(|_| String::from("cli arguments already parsed"))?;
×
40
        Ok(CLI_ARGUMENTS.get().ok_or("cli arguments not set? this should never happen")?)
×
41
    }
42

43
    /// Get a reference to the parsed CLI args. Will panic, if the CLI args have not been parsed using
44
    /// `Self::init()` prior to calling this function.
45
    #[allow(clippy::expect_used)]
46
    pub fn get_or_panic() -> &'static Self {
×
47
        CLI_ARGUMENTS.get().expect("cli arguments should have been set")
×
48
    }
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc