Compare commits

..

6 Commits

Author SHA1 Message Date
Jonathan Strong 8a719e7c6c misc loose ends 2 years ago
Jonathan Strong c28a3c8f87 re-generate docs 2 years ago
Jonathan Strong 3241e2075c update deps and bump version to v0.4.1 2 years ago
Jonathan Strong 6281152a84 improve error reporting when config toml file fails to parse (still a bit meh) 2 years ago
Jonathan Strong bd0e3ccda7 impl Default for HttpConfig, so field isn't required in config file 2 years ago
Jonathan Strong 86039a16e6 update crate vers in lock file 2 years ago
  1. 484
      Cargo.lock
  2. 2
      Cargo.toml
  3. 6
      README.md
  4. 4
      doc/cli-menu.txt
  5. 4
      justfile
  6. 20
      src/main.rs

484
Cargo.lock generated

File diff suppressed because it is too large Load Diff

2
Cargo.toml

@ -1,7 +1,7 @@
[package] [package]
name = "registry-backup" name = "registry-backup"
authors = ["Jonathan Strong <jstrong@shipyard.rs>"] authors = ["Jonathan Strong <jstrong@shipyard.rs>"]
version = "0.4.0" version = "0.4.1"
edition = "2021" edition = "2021"
publish = ["shipyard-rs-public"] publish = ["shipyard-rs-public"]
readme = "README.md" readme = "README.md"

6
README.md

@ -39,7 +39,7 @@ $ cargo install registry-backup --git https://git.shipyard.rs/jstrong/registry-b
```console ```console
$ ./target/release/registry-backup --help $ ./target/release/registry-backup --help
registry-backup 0.4.0 registry-backup 0.4.1
Jonathan Strong <jstrong@shipyard.rs> Jonathan Strong <jstrong@shipyard.rs>
Download all .crate files from a registry server Download all .crate files from a registry server
@ -82,7 +82,7 @@ OPTIONS:
-U, --user-agent <USER_AGENT> -U, --user-agent <USER_AGENT>
Value of user-agent HTTP header Value of user-agent HTTP header
[default: registry-backup/v0.4.0] [default: registry-backup/v0.4.1]
-R, --requests-per-second <INT> -R, --requests-per-second <INT>
Requests to registry server will not exceed this rate Requests to registry server will not exceed this rate
@ -193,7 +193,7 @@ The commands that mirror cargo commands (e.g. `just test`) are included for the
This file is generated using a template (`doc/README.tera.md`) rendered using updated outputs of the CLI menu, config sample, and other values. This file is generated using a template (`doc/README.tera.md`) rendered using updated outputs of the CLI menu, config sample, and other values.
This version of `README.md` was generated at `Thu, 15 Sep 2022 20:34:23 +0000` based on git commit `01ce9284`. This version of `README.md` was generated at `Thu, 08 Dec 2022 02:23:17 +0000` based on git commit `3241e207`.
To (re-)generate the `README.md` file, use the justfile command: To (re-)generate the `README.md` file, use the justfile command:

4
doc/cli-menu.txt

@ -1,4 +1,4 @@
registry-backup 0.4.0 registry-backup 0.4.1
Jonathan Strong <jstrong@shipyard.rs> Jonathan Strong <jstrong@shipyard.rs>
Download all .crate files from a registry server Download all .crate files from a registry server
@ -41,7 +41,7 @@ OPTIONS:
-U, --user-agent <USER_AGENT> -U, --user-agent <USER_AGENT>
Value of user-agent HTTP header Value of user-agent HTTP header
[default: registry-backup/v0.4.0] [default: registry-backup/v0.4.1]
-R, --requests-per-second <INT> -R, --requests-per-second <INT>
Requests to registry server will not exceed this rate Requests to registry server will not exceed this rate

4
justfile

@ -60,7 +60,9 @@ update-readme-and-commit: update-readme-and-stage
git commit -m 're-generate docs' git commit -m 're-generate docs'
# get everything all ready for release # get everything all ready for release
release-prep: verify-clean-git pre-release release-prep:
just pre-release
just verify-clean-git
VERSION=$(just get-crate-version) \ VERSION=$(just get-crate-version) \
&& test -z "$(git tag | rg \"v${VERSION}\")" # Error: tag appears to exist already && test -z "$(git tag | rg \"v${VERSION}\")" # Error: tag appears to exist already
just update-readme-and-commit just update-readme-and-commit

20
src/main.rs

@ -194,6 +194,7 @@ pub struct Config {
pub output: OutputConfig, pub output: OutputConfig,
/// Download settings /// Download settings
#[clap(flatten)] #[clap(flatten)]
#[serde(default)]
pub http: HttpConfig, pub http: HttpConfig,
/// Specify configuration values using the provided TOML file, instead of /// Specify configuration values using the provided TOML file, instead of
/// via command line flags. The values in the config file will override /// via command line flags. The values in the config file will override
@ -274,6 +275,16 @@ impl std::fmt::Debug for TargetRegistryConfig {
} }
} }
impl Default for HttpConfig {
fn default() -> Self {
Self {
user_agent: default_user_agent(),
requests_per_second: default_requests_per_second(),
max_concurrent_requests: default_max_concurrent_requests(),
}
}
}
impl std::fmt::Debug for HttpConfig { impl std::fmt::Debug for HttpConfig {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("Config") f.debug_struct("Config")
@ -370,7 +381,14 @@ async fn load_config_file(config: Config) -> Result<Config, AnyError> {
Some(path) => { Some(path) => {
debug!(?path, "loading config file"); debug!(?path, "loading config file");
let toml = tokio::fs::read_to_string(&path).await?; let toml = tokio::fs::read_to_string(&path).await?;
let config: Config = toml::from_str(&toml)?; let config: Config = match toml::from_str(&toml) {
Ok(c) => c,
Err(e) => panic!(
"\nfatal error: parsing config file at {} failed:\n\n{}\n\n",
path.display(),
e
),
};
Ok(config) Ok(config)
} }

Loading…
Cancel
Save