-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
many dependencies, but also convenience and safety
- Loading branch information
Showing
4 changed files
with
148 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
#[macro_use] | ||
extern crate clap; | ||
extern crate git_core as git; | ||
use anyhow::{Context, Result}; | ||
use git_core; | ||
use structopt::StructOpt; | ||
|
||
mod app { | ||
use clap::{App, AppSettings, SubCommand}; | ||
mod options { | ||
use structopt::StructOpt; | ||
|
||
pub fn new<'a, 'b>() -> App<'a, 'b> { | ||
let app: App = app_from_crate!(); | ||
app.setting(AppSettings::SubcommandRequired).subcommand( | ||
SubCommand::with_name("init") | ||
.alias("initialize") | ||
.about("Initialize the repository in the current directory."), | ||
) | ||
#[derive(Debug, StructOpt)] | ||
#[structopt(about = "The git, simply swift")] | ||
#[structopt(setting = structopt::clap::AppSettings::SubcommandRequired)] | ||
pub struct Args { | ||
#[structopt(subcommand)] | ||
pub cmd: Subcommands, | ||
} | ||
|
||
#[derive(Debug, StructOpt)] | ||
pub enum Subcommands { | ||
/// Initialize the repository in the current directory. | ||
#[structopt(alias = "initialize")] | ||
Init, | ||
} | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let app = app::new(); | ||
let matches = app.get_matches(); | ||
match matches.subcommand() { | ||
("init", Some(_args)) => { | ||
git::init::repository().with_context(|| "Repository initialization failed") | ||
let args = options::Args::from_args(); | ||
match args.cmd { | ||
options::Subcommands::Init => { | ||
git_core::init::repository().with_context(|| "Repository initialization failed") | ||
} | ||
_ => unreachable!(), | ||
}?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### TODO | ||
|
||
* [x] remove failure and replace with quick-check/anyhow | ||
* [x] minimize dependencies and test-runs | ||
* [ ] structopt for grit | ||
* [ ] make parser tests unit tests that are close to the code they test | ||
* [ ] parser tests handle binary strings nicely | ||
* [ ] switch parsing to nom (binary only) |