Browse Source

adds --skip and --limit options

feat/mass-publish-tool
Jonathan Strong 1 year ago
parent
commit
69afa9a804
  1. 19
      src/publish.rs

19
src/publish.rs

@ -40,6 +40,17 @@ struct Opt {
/// the config file.
#[clap(long, value_name = "REGEX", alias = "filter")]
pub filter_crates: Option<String>,
/// Option to limit the number of crate versions published. If set, when the
/// number is reached the program will exit.
#[clap(long, short = 'n', value_name = "INT")]
pub limit: Option<usize>,
/// Option to skip a number of crate versions at the beginning of the dependency
/// order, for use if resuming. The skipped versions will not count as part of
/// the optional --limit.
#[clap(long, value_name = "INT")]
pub skip: Option<usize>,
}
#[derive(Debug, Clone, Deserialize)]
@ -707,7 +718,7 @@ fn prepare_source_dirs_for_publish(
fn cargo_publish_modified_source_dir(config: &Config, meta: &VersionMeta) -> Result<(), Error> {
let begin = Instant::now();
info!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "publishing crate version");
debug!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "publishing crate version");
let index_env_key = format!(
"CARGO_REGISTRIES_{}_INDEX",
config.dst.registry_name.to_case(Case::ScreamingSnake)
@ -858,7 +869,11 @@ fn main() -> Result<(), Error> {
.flat_map(|(k, v)| v.iter().map(|m| ((k.as_str(), &m.index_meta.vers), m)))
.collect();
for row in publish_log.iter() {
let skip = opt.skip.unwrap_or(0);
let limit = opt.limit.unwrap_or(publish_log.len());
debug!(skip, limit, n_total_versions = publish_log.len(), "ready to publish!");
for row in publish_log.iter().skip(skip).take(limit) {
let Some(meta) = by_name_vers.remove(&(row.crate_name.as_str(), &row.version)) else {
warn!(
?row,

Loading…
Cancel
Save