pub mod fetch; pub mod index; pub mod lock; pub mod run; const DICT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/dict.bin")); /// nix2cargo: reproducible cargo locks #[derive(clap::Parser)] pub struct Cli { #[command(subcommand)] pub command: Command, } #[derive(clap::Subcommand)] pub enum Command { /// Fetch a revision of the index Fetch(fetch::Cmd), /// Refresh the nix2cargo lockfile Lock(lock::Cmd), /// Run the cargo wrapper Run(run::Cmd), } impl Cli { pub fn exec(self) { let Self { command } = self; let res = match command { Command::Fetch(cmd) => cmd.exec(), Command::Lock(cmd) => cmd.exec(), Command::Run(cmd) => cmd.exec(), }; match res { Ok(()) => (), Err(err) => { eprintln!("nix2cargo: {err}"); std::process::exit(1) } } } } fn agent() -> ureq::Agent { ureq::Agent::config_builder() .tls_config( ureq::tls::TlsConfig::builder() .root_certs(ureq::tls::RootCerts::PlatformVerifier) .build(), ) .build() .into() }