use std::path::PathBuf;

use crate::Result;

use super::trust;

/// Remove explicit trust for a config
#[derive(Debug, usage_rs::Args)]
#[usage(verbatim_doc_comment)]
pub(crate) struct Untrust {
    /// The config file to untrust
    #[usage(value_hint = ValueHint::FilePath, verbatim_doc_comment)]
    config_file: Option<PathBuf>,
}

impl Untrust {
    pub(crate) fn run(self) -> Result<()> {
        trust::untrust_config_file(self.config_file())
    }

    fn config_file(&self) -> Option<PathBuf> {
        trust::resolve_config_file(self.config_file.as_ref())
    }
}
