use crate::{ app::AppaService, cli::{FolderCommand, IdentityCommand}, }; const REPLACE_EXISTING_IDENTITY: bool = true; pub(super) fn run_identity_command( appa: &AppaService, command: Option, ) -> anyhow::Result<()> { match command { None => println!("{}", appa.device_identity()?), Some(IdentityCommand::Export { path }) => { appa.export_identity(&path)?; println!( "Exported sensitive Appa identity backup to {}.", path.display() ); } Some(IdentityCommand::Import { path, yes }) => { if !yes && !dialoguer::Confirm::new() .with_prompt("Replace this device's Appa identity?") .interact()? { return Ok(()); } appa.import_identity(&path, REPLACE_EXISTING_IDENTITY)?; println!("Imported Appa identity from {}.", path.display()); } } Ok(()) } pub(super) fn run_folder_command(appa: &AppaService, command: FolderCommand) -> anyhow::Result<()> { match command { FolderCommand::Template { path } => { appa.export_folder_inventory(&path)?; println!("Wrote local folder inventory to {}.", path.display()); } FolderCommand::Validate { path } => { appa.validate_folder_inventory(&path)?; println!("{} is valid.", path.display()); } FolderCommand::Import { path } => { let folders = appa.import_folder_inventory(&path)?; println!( "Imported {} folder(s) from {}.", folders.len(), path.display() ); } _ => unreachable!("only folder inventory commands reach local setup"), } Ok(()) }