diff --git a/CHANGELOG.md b/CHANGELOG.md index 6695114..c3107d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +v0.6.0 (in development) +----------------------- +- `apply`: The argument to `--repo-file` can now be `-` to read from standard + input + v0.5.0 (2023-11-06) ------------------- - The log message emitted before each API request is now emitted after the log diff --git a/Cargo.lock b/Cargo.lock index 7eae4d9..2e97893 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,7 +641,7 @@ dependencies = [ [[package]] name = "labelmaker" -version = "0.5.0" +version = "0.6.0-dev" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index 30743cc..19f6baa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "labelmaker" -version = "0.5.0" +version = "0.6.0-dev" edition = "2021" rust-version = "1.70" description = "Create & enforce sets of labels in GitHub repositories" diff --git a/README.md b/README.md index aa33990..7b4a4bc 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,9 @@ made. showing what would be changed. - `-F FILE`/`--repo-file FILE` — Also operate on all repositories listed in the - given file. Repositories must be listed one per line. Leading & trailing - whitespace is ignored. Blank lines and lines starting with `#` are skipped. + given file (or listed on standard input if `FILE` is `-`). Repositories must + be listed one per line. Leading & trailing whitespace is ignored. Blank + lines and lines starting with `#` are skipped. - `-P NAME`/`--profile NAME` — Specify which profile in the configuration file to use. Defaults to the value of `defaults.profile` in the configuration diff --git a/src/main.rs b/src/main.rs index 381a872..dcdffdb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use anyhow::Context; use clap::{builder::ArgAction, Args, Parser, Subcommand}; use ghrepo::{GHRepo, LocalRepo}; use log::{Level, LevelFilter}; -use std::io::{self, BufRead}; +use std::io; use std::path::PathBuf; use std::process::ExitCode; @@ -66,7 +66,7 @@ enum Command { /// whitespace is ignored. Blank lines and lines starting with '#' are /// skipped. #[arg(short = 'F', long, value_name = "FILE")] - repo_file: Option, + repo_file: Option, /// A configuration file describing what labels to create and/or update /// in each repository @@ -124,11 +124,9 @@ impl Command { }; let mut repo_parser = RepoParser::new(&client); if let Some(p) = repo_file { - let fp = std::fs::File::open(&p) - .with_context(|| format!("failed to open {}", p.display()))?; - for ln in io::BufReader::new(fp).lines() { - let ln = - ln.with_context(|| format!("failed to read from {}", p.display()))?; + let lines = p.lines().with_context(|| format!("failed to open {p:#}"))?; + for ln in lines { + let ln = ln.with_context(|| format!("failed to read from {p:#}"))?; let ln = ln.trim(); if !(ln.is_empty() || ln.starts_with('#')) { repository.push(ln.to_owned());