diff --git a/src/lean.rs b/src/lean.rs new file mode 100644 index 0000000..498d5c4 --- /dev/null +++ b/src/lean.rs @@ -0,0 +1 @@ +pub mod elan; diff --git a/src/lean/elan.rs b/src/lean/elan.rs new file mode 100644 index 0000000..8b45b8d --- /dev/null +++ b/src/lean/elan.rs @@ -0,0 +1,9 @@ +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +pub struct ElanConfig { + #[structopt(long, default_value = "3")] + pub retain_elan_versions: usize, + #[structopt(long, default_value = "30")] + pub retain_lean_versions: usize, +} diff --git a/src/main.rs b/src/main.rs index 751ae29..04a2ce5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,7 @@ mod html_scanner; mod index_pipe; #[macro_use] mod merge_pipe; +mod lean; mod metadata; mod opts; mod pypi; @@ -226,7 +227,7 @@ fn main() { let script_src = rewrite_pipe::RewritePipe::new( stream_pipe::ByteStreamPipe::new( source.get_script(), - buffer_path.clone().unwrap(), + buffer_path.clone().expect("buffer path is not present"), false, ), buffer_path.clone().unwrap(), @@ -321,6 +322,36 @@ fn main() { index_bytes_pipe!(buffer_path, prefix, false, 999) ); } + Source::Elan(source) => { + let elan_src = stream_pipe::ByteStreamPipe::new( + GitHubRelease::new( + String::from("leanprover/elan"), + source.retain_elan_versions, + ), + buffer_path.clone().unwrap(), + true, + ); + let lean_src = stream_pipe::ByteStreamPipe::new( + GitHubRelease::new( + String::from("leanprover/lean4"), + source.retain_lean_versions, + ), + buffer_path.clone().unwrap(), + true, + ); + let unified = merge_pipe! { + elan: elan_src, + lean: lean_src, + }; + let indexed = index_pipe::IndexPipe::new( + unified, + buffer_path.clone().unwrap(), + prefix.clone().unwrap(), + 999, + ); + + transfer!(opts, indexed, transfer_config, id_pipe!()); + } } }); } diff --git a/src/opts.rs b/src/opts.rs index 64771f3..f24f017 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -6,6 +6,7 @@ use crate::ghcup::Ghcup as GhcupConfig; use crate::github_release::GitHubRelease; use crate::gradle::Gradle; use crate::homebrew::HomebrewConfig; +use crate::lean::elan::ElanConfig; use crate::pypi::Pypi as PypiConfig; use crate::rsync::Rsync as RsyncConfig; use crate::rustup::Rustup as RustupConfig; @@ -37,6 +38,8 @@ pub enum Source { Gradle(Gradle), #[structopt(about = "rustup")] Rustup(RustupConfig), + #[structopt(about = "elan")] + Elan(ElanConfig), } #[derive(Debug)] diff --git a/src/pypi.rs b/src/pypi.rs index 4e853ed..a799779 100644 --- a/src/pypi.rs +++ b/src/pypi.rs @@ -193,7 +193,7 @@ async fn bigquery_index(logger: &Logger) -> Result> { fn version_from_filename(filename: &str) -> Option { static RE_VERSION: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { - Regex::new(r#"^\w+-([\w.-_+]+).*(.tar.gz|tar.bz2|.zip|.whl|.exe|.egg)$"#).unwrap() + Regex::new(r"^\w+-([\w.-_+]+).*(.tar.gz|tar.bz2|.zip|.whl|.exe|.egg)$").unwrap() }); RE_VERSION .captures(filename)