Skip to content

Commit

Permalink
Add structopt, you can now see commits in arbitrary directories
Browse files Browse the repository at this point in the history
  • Loading branch information
sondr3 committed Oct 15, 2018
1 parent c6c5834 commit a55ab94
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "git-anger-management"
version = "0.2.0"
version = "0.3.0"
authors = ["Sondre Nilsen <nilsen.sondre@gmail.com>"]
homepage = "https://github.com/sondr3/git-anger-management"
description = "Count your naughty words in git commit messages"
Expand All @@ -21,3 +21,4 @@ fail-on-warnings = []

[dependencies]
git2 = "0.7"
structopt = "0.2"
24 changes: 23 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
#![cfg_attr(feature = "fail-on-warnings", deny(warnings))]
#![forbid(unsafe_code)]
extern crate git2;
#[macro_use]
extern crate structopt;

use git2::{Commit, Repository};
use std::cmp::PartialEq;
use std::collections::HashMap;
use std::env;
use std::path::PathBuf;
use std::error::Error;
use structopt::clap::AppSettings;
use structopt::StructOpt;

static CURSES: &str = include_str!("words.txt");

#[derive(StructOpt, Debug)]
#[structopt(
name = "git anger-management",
about = "Ever wondered how angry your commits are? Look no further...",
raw(global_settings = "&[AppSettings::ColoredHelp]")
)]
struct Cli {
#[structopt(name = "directory", help = "Directory to parse commits", parse(from_os_str))]
directory: Option<PathBuf>,
}

#[derive(Debug, Eq)]
struct Author {
name: String,
Expand Down Expand Up @@ -47,8 +63,14 @@ impl Author {
}

fn main() -> Result<(), Box<Error>> {
let opt = Cli::from_args();
let curses: Vec<&str> = CURSES.lines().collect();
let path = env::current_dir()?;
let path;
if opt.directory.is_none() {
path = env::current_dir()?;
} else {
path = PathBuf::from(opt.directory.unwrap());
}
let repo = Repository::open(path)?;
let mut revwalk = repo.revwalk()?;
let mut commits: Vec<Commit> = Vec::new();
Expand Down

0 comments on commit a55ab94

Please sign in to comment.