ordinaryd 0.8.0

Ordinary Server
// Copyright (C) 2026 Ordinary Labs, LLC.
//
// SPDX-License-Identifier: AGPL-3.0-only

use clap::ValueEnum;
use clap::builder::PossibleValue;
use std::fmt::Display;

/// stdio log formatting
#[derive(Clone, Debug)]
pub enum StdioLogFmt {
    Concise,
    Pretty,
    Json,
}

impl ValueEnum for StdioLogFmt {
    fn value_variants<'a>() -> &'a [Self] {
        &[Self::Concise, Self::Pretty, Self::Json]
    }

    fn to_possible_value(&self) -> Option<PossibleValue> {
        match self {
            Self::Concise => Some(PossibleValue::new("concise")),
            Self::Pretty => Some(PossibleValue::new("pretty")),
            Self::Json => Some(PossibleValue::new("json")),
        }
    }
}

impl Display for StdioLogFmt {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let str = match self {
            Self::Concise => "concise",
            Self::Pretty => "pretty",
            Self::Json => "json",
        };

        write!(f, "{str}")
    }
}