Add git-edit-coauthor command
It is now possible to edit the available co-authors, in case you misspelled someone's name, or they change their email address, or something.
This commit is contained in:
parent
64f7a10cd1
commit
609cdf83d8
|
|
@ -158,7 +158,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "git_mob"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"git2",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "git_mob"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Martin Frost <martin@frost.ws>"]
|
||||
edition = "2018"
|
||||
description = "A CLI tool for social coding."
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ It is essentially a Rust clone of the [git-mob NPM package](https://www.npmjs.co
|
|||
* Add Alice and Bob as a possible co-authors:
|
||||
|
||||
git add-coauthor a "Alice" alice@example.com
|
||||
git add-coauthor b "Bob" bob@example.com
|
||||
git add-coauthor b "bob" Bob@example.com
|
||||
|
||||
* Set Alice as co-author, making your mob consist of you and Alice:
|
||||
|
||||
|
|
@ -24,6 +24,10 @@ It is essentially a Rust clone of the [git-mob NPM package](https://www.npmjs.co
|
|||
|
||||
git mob a b
|
||||
|
||||
* Edit Bob's name, since you accidentally capitalized his email instead of his name:
|
||||
|
||||
git edit-coauthor b --name "Bob" --email bob@example.com
|
||||
|
||||
* Remove Bob as a possible co-author:
|
||||
|
||||
git delete-coauthor b
|
||||
|
|
@ -41,6 +45,7 @@ It is essentially a Rust clone of the [git-mob NPM package](https://www.npmjs.co
|
|||
|
||||
* `git mob <co-author-initials>`
|
||||
* `git add-coauthor <initials> "Co-author Name" <co-author-email-address>`
|
||||
* `git edit-coauthor [--name "Co-author Name"] [--email <co-author-email-address>]`
|
||||
* `git delete-coauthor <initials>`
|
||||
* `git mob -l`
|
||||
* `git solo`
|
||||
|
|
@ -55,7 +60,6 @@ be implemented, and then there is also a severe lack of tests and documentation.
|
|||
### Missing features
|
||||
|
||||
* `git mob-print`
|
||||
* `git edit-coauthor`
|
||||
* `git suggest-coauthors`
|
||||
* `-o` for overwriting the main author
|
||||
* `--installTemplate` and `--uninstallTemplate` for prepare-commit-msg
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
use git_mob::{Author, get_available_coauthors, write_coauthors_file} ;
|
||||
use structopt::StructOpt;
|
||||
use std::process;
|
||||
|
||||
#[derive(StructOpt,Debug)]
|
||||
struct Opt {
|
||||
/// Co-author initials
|
||||
initials: String,
|
||||
/// The name of the co-author, in quotes, e.g. "Foo Bar"
|
||||
#[structopt(long, required_unless("email"))]
|
||||
name: Option<String>,
|
||||
/// The email of the co-author
|
||||
#[structopt(long, required_unless("name"))]
|
||||
email: Option<String>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let opt = Opt::from_args();
|
||||
|
||||
let mut authors = get_available_coauthors();
|
||||
let mut updated_author : Author;
|
||||
|
||||
if let Some(author) = authors.get(&opt.initials) {
|
||||
updated_author = author.clone();
|
||||
} else {
|
||||
eprintln!("No author found with initials {}", &opt.initials);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
if let Some(name) = opt.name {
|
||||
updated_author.name = name;
|
||||
}
|
||||
|
||||
if let Some(email) = opt.email {
|
||||
updated_author.email = email;
|
||||
}
|
||||
|
||||
authors.insert(opt.initials, updated_author);
|
||||
|
||||
write_coauthors_file(authors);
|
||||
}
|
||||
Loading…
Reference in New Issue