git_simple_encrypt/
lib.rs1#![warn(clippy::nursery, clippy::cargo, clippy::pedantic)]
2#![allow(clippy::missing_errors_doc)]
3#![allow(clippy::missing_panics_doc)]
4#![allow(clippy::multiple_crate_versions)]
5
6pub mod config;
7pub mod crypt;
8mod error;
9pub mod repo;
10pub mod salt_cache;
11pub mod utils;
12
13#[cfg(feature = "bin")]
14mod cli;
15
16#[cfg(feature = "bin")]
17pub use crate::cli::{Cli, SetField, SubCommand};
18#[cfg(feature = "bin")]
19use crate::crypt::{decrypt_repo, encrypt_repo};
20#[cfg(feature = "bin")]
21use crate::repo::Repo;
22pub use crate::{
23 crypt::{BatchSummary, FileHeader},
24 error::{Error, Result},
25};
26
27#[cfg(feature = "bin")]
31pub fn run(cli: Cli) -> Result<()> {
32 if !cli.repo.is_absolute() {
33 return Err(Error::RepoPathNotAbsolute(cli.repo.clone()));
34 }
35 let mut repo = Repo::open(&cli.repo)?;
36 match cli.command {
37 SubCommand::Encrypt { paths } => encrypt_repo(&repo, &paths)?,
38 SubCommand::Decrypt { paths } => decrypt_repo(&repo, &paths)?,
39 SubCommand::Add { paths } => repo.conf.add_paths_to_crypt_list(&paths)?,
40 SubCommand::Set { field } => field.set(&mut repo)?,
41 SubCommand::Pwd => repo.set_key_interactive()?,
42 SubCommand::Check { paths, staged } => repo.check(&paths, staged)?,
43 SubCommand::Install => repo.install_hook()?,
44 }
45 Ok(())
46}