all: sync up with other Rust repos

This commit is contained in:
Harsh Shandilya 2022-02-06 16:11:20 +05:30
parent e0deedafca
commit 593a73a506
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
9 changed files with 161 additions and 88 deletions

View file

@ -1,37 +1,28 @@
use clap::{crate_authors, crate_description, crate_name, crate_version, AppSettings, Clap};
use clap::{AppSettings, Parser};
#[derive(Clap)]
#[clap(
name = crate_name!(),
version = crate_version!(),
author = crate_authors!(),
about = crate_description!(),
setting = AppSettings::ColoredHelp,
setting = AppSettings::DeriveDisplayOrder,
setting = AppSettings::SubcommandRequiredElseHelp,
)]
#[derive(Parser)]
#[clap(author, version, about)]
#[clap(global_setting(AppSettings::DeriveDisplayOrder))]
pub(crate) struct Opts {
#[clap(subcommand)]
pub(crate) subcommand: SubCommand,
}
#[derive(Clap)]
#[derive(Parser)]
pub(crate) enum SubCommand {
Freeze(Freeze),
Thaw(Thaw),
}
/// recursively find git repos and record their states into a lockfile
#[derive(Clap)]
#[clap(setting = AppSettings::ColoredHelp)]
#[derive(Parser)]
pub(crate) struct Freeze {
/// directory to search and freeze repos from.
pub(crate) directory: String,
}
/// takes the given
#[derive(Clap)]
#[clap(setting = AppSettings::ColoredHelp)]
/// takes the given lockfile and clones them back into the given directory
#[derive(Parser)]
pub(crate) struct Thaw {
/// directory to put cloned repos into.
pub(crate) directory: String,

View file

@ -73,9 +73,9 @@ pub(crate) fn thaw_repos(dir: &str, lockfile: &str) -> anyhow::Result<()> {
.expect("Failed to run `git clone`. Perhaps git is not installed?");
if output.status.success() {
println!("Thawed {} successfully.", name)
println!("Thawed {} successfully.", name);
} else {
println!("{}", std::str::from_utf8(&output.stderr)?)
println!("{}", std::str::from_utf8(&output.stderr)?);
}
}

View file

@ -2,9 +2,8 @@ pub(crate) mod cli;
pub(crate) mod git;
pub(crate) mod model;
use clap::Clap;
use cli::Opts;
use cli::SubCommand;
use clap::Parser;
use cli::{Opts, SubCommand};
use git::freeze_repos;
use git::thaw_repos;