Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/dump.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Print the debug form of a parsed patch.

use std::{
env::args,
fs::read_to_string,
io::{stdin, Read},
};

use gitpatch::Patch;

fn main() {
let mut patch_text = String::new();
if let Some(filename) = args().nth(1) {
patch_text = read_to_string(filename).unwrap();
} else {
stdin().read_to_string(&mut patch_text).unwrap();
};
let patch = Patch::from_multiple(&patch_text).unwrap();
println!("{:#?}", patch);
}
22 changes: 22 additions & 0 deletions examples/reproduce.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! Parse a patch from a file or stdin, then print it out as a patch.

use std::{
env::args,
fs::read_to_string,
io::{stdin, Read},
};

use gitpatch::Patch;

fn main() {
let mut patch_text = String::new();
if let Some(filename) = args().nth(1) {
patch_text = read_to_string(filename).unwrap();
} else {
stdin().read_to_string(&mut patch_text).unwrap();
};
let patches = Patch::from_multiple(&patch_text).unwrap();
for patch in patches {
println!("{}", patch);
}
}