/// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public function 'run'. Replace with real documentation. (2025-12-30T22:23:21Z)
///
/// # Errors
/// Returns `KamError` if secret operations fail (I/O errors, encryption/decryption failures, invalid input).
pub fn run(args: SecretArgs) -> Result<(), KamError> {
    if args.interactive {
        if args.command.is_some() {
            return Err(KamError::CommandFailed(crate::i18n::tr(
                "secret.interactive.error.conflict_with_subcommand",
            )));
        }
        return interactive_secrets();
    }

    let Some(cmd) = args.command else {
        return Err(KamError::CommandFailed(crate::i18n::tr(
            "secret.error.no_subcommand",
        )));
    };

    match cmd {
        SecretCommands::List => handle_list()?,
        SecretCommands::Add {
            name,
            file,
            file_path,
            value,
            force_file,
            password,
            with_backup,
        } => handle_add(
            &name,
            file.as_ref(),
            file_path.as_ref(),
            value.as_deref(),
            force_file,
            password.as_deref(),
            with_backup,
        )?,
        SecretCommands::Get {
            name,
            out,
            password,
        } => handle_get(&name, out.as_ref(), password.as_deref())?,
        SecretCommands::Remove { name } => handle_remove(&name)?,
        SecretCommands::Export {
            name,
            path,
            encrypted,
        } => handle_export(&name, &path, encrypted)?,
        SecretCommands::Import { path, name } => handle_import(&path, name)?,
        SecretCommands::ExportPub { name, out } => handle_export_pub(&name, out)?,
        SecretCommands::ImportCert {
            repo,
            issue,
            cert_chain,
            name,
        } => handle_import_cert(repo, issue, cert_chain.as_ref(), &name)?,
        SecretCommands::Trust {
            add_root,
            ca_name,
            list,
            remove,
        } => handle_trust(add_root, ca_name, list, remove)?,
        SecretCommands::KsuGenerate {
            name,
            out,
            no_gpg,
            force,
        } => handle_ksu_generate(&name, &out, no_gpg, force)?,
        SecretCommands::KsuSubmit {
            username,
            public_key,
            open,
        } => handle_ksu_submit(&username, &public_key, open)?,
        SecretCommands::KsuRevoke {
            username,
            serial_number,
            cert,
            reason,
            details,
            open,
        } => handle_ksu_revoke(&username, serial_number, cert, &reason, &details, open)?,
    }
    Ok(())
}
