Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
demidko committed Mar 11, 2024
1 parent 271ce62 commit f984633
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 232 deletions.
216 changes: 0 additions & 216 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.2", features = ["derive"] }
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ cargo install --git https://github.com/demidko/archdiff

## Usage example

Compare with branch `dev`:

```shell
archdiff --git git@github.com:myname/myrepo.git --from-branch dev --into-branch main
archdiff dev
```
3 changes: 3 additions & 0 deletions src/arch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn read() -> String {
todo!()
}
26 changes: 26 additions & 0 deletions src/git.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::process::Command;

pub fn co(branch: &str) {
let status =
Command::new("git")
.arg("checkout")
.arg(branch)
.status()
.expect("failed to find git");
assert!(status.success())
}

pub fn current_branch() -> String {
let output =
Command::new("git")
.arg("branch")
.arg("--show-current")
.output()
.expect("failed to find git")
.stdout;
String::from_utf8(output).expect("failed to find current branch")
}

pub fn diff(from: &str, into: &str) -> String {
todo!()
}
28 changes: 14 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use clap::Parser;
use std::env::args;

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long)]
from_branch: String,
use clap::Parser;

#[arg(short, long)]
into_branch: String,
}
mod git;
mod arch;

fn main() {
let Args { from_branch, into_branch } = Args::parse();
let from_arch = read_arch(from_branch);
let into_arch = read_arch(into_branch);
let arch_diff = git_diff(from_arch, into_arch);
println!("{}", arch_diff);
let from_branch = args().nth(1).expect("expected source branch name");
let into_branch = git::current_branch();

git::co(&from_branch);
let from_branch = arch::read();

git::co(&into_branch);
let into_branch = arch::read();

println!("{}", git::diff(&from_branch, &into_branch));
}

0 comments on commit f984633

Please sign in to comment.