| Crates.io | cicero_distribution |
| lib.rs | cicero_distribution |
| version | 0.4.1 |
| created_at | 2024-09-07 09:07:13.565209+00 |
| updated_at | 2025-05-19 17:51:25.768122+00 |
| description | Bundle distribution files in CI code. |
| homepage | |
| repository | https://codeberg.org/trem/cicero/ |
| max_upload_size | |
| id | 1367059 |
| size | 75,593 |
Need to pack multiple files into a distribution?
Cicero provides an API for specifying the file structure and then deferring to your functions to provide the contents:
use std::{fs, path::Path};
use cicero_distribution::Distribution;
use cicero_path::repo_path;
fn main() -> anyhow::Result<()> {
let distribution = Distribution::new("myproject")?;
distribution
.add_file_from_path("README.md", repo_path!("README.md"))?
.add_file("myproject", |file| build_backend_executable(file))?;
distribution
.dir_unstructured("public", |dir| build_frontend(dir))?;
let distribution_dir = distribution.bundle_as_dir()?;
Ok(())
}
fn build_frontend(out_dir: &Path) -> anyhow::Result<()> {
let build_out_dir: &Path = unimplemented!();
fs::rename(build_out_dir, out_dir)?;
Ok(())
}
fn build_backend_executable(out_file: &Path) -> anyhow::Result<()> {
let build_out_file: &Path = unimplemented!();
fs::rename(build_out_file, out_file)?;
Ok(())
}
Advantages to this approach:
File structure is documented and trivially correct.
Conflicts due to two code locations modifying the same files are practically eliminated.
Obvious where to jump into the code to change a portion of the distribution.
Less path wrangling. Your function has the complete path passed to it. No need to modify it further.
Your functions become naturally testable. You can pass a temporary path (e.g. from assert_fs) instead and assert on that.
Mind that this API may still see larger changes, as more features are implemented.