Skip to content

Commit 1b9b12d

Browse files
committed
Initial commit
0 parents  commit 1b9b12d

File tree

15 files changed

+428
-0
lines changed

15 files changed

+428
-0
lines changed

.github/example-cmd.png

20.3 KB
Loading

.github/example-ps.png

49 KB
Loading

.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Rust template
3+
# Generated by Cargo
4+
# will have compiled files and executables
5+
/target/
6+
7+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
8+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
9+
Cargo.lock
10+
11+
# These are backup files generated by rustfmt
12+
**/*.rs.bk
13+
### JetBrains template
14+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
15+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
16+
17+
# User-specific stuff
18+
.idea/**/workspace.xml
19+
.idea/**/tasks.xml
20+
.idea/**/dictionaries
21+
.idea/**/shelf
22+
23+
# Sensitive or high-churn files
24+
.idea/**/dataSources/
25+
.idea/**/dataSources.ids
26+
.idea/**/dataSources.local.xml
27+
.idea/**/sqlDataSources.xml
28+
.idea/**/dynamic.xml
29+
.idea/**/uiDesigner.xml
30+
.idea/**/dbnavigator.xml
31+
32+
# Gradle
33+
.idea/**/gradle.xml
34+
.idea/**/libraries
35+
36+
# CMake
37+
cmake-build-debug/
38+
cmake-build-release/
39+
40+
# Mongo Explorer plugin
41+
.idea/**/mongoSettings.xml
42+
43+
# File-based project format
44+
*.iws
45+
46+
# IntelliJ
47+
out/
48+
49+
# mpeltonen/sbt-idea plugin
50+
.idea_modules/
51+
52+
# JIRA plugin
53+
atlassian-ide-plugin.xml
54+
55+
# Cursive Clojure plugin
56+
.idea/replstate.xml
57+
58+
# Crashlytics plugin (for Android Studio and IntelliJ)
59+
com_crashlytics_export_strings.xml
60+
crashlytics.properties
61+
crashlytics-build.properties
62+
fabric.properties
63+
64+
# Editor-based Rest Client
65+
.idea/httpRequests
66+

.idea/compiler.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "colored-diff"
3+
version = "0.1.0"
4+
authors = ["Christopher Durham <[email protected]>"]
5+
6+
license = "MIT OR Unlicense"
7+
readme = "README.md"
8+
description = "Format the difference between two strings with ANSI colors"
9+
repository = "https://github.com/CAD97/colored-diff"
10+
keywords = ["pretty-assertions", "diff", "difference"]
11+
categories = ["development-tools::testing"]
12+
13+
exclude = ["/.github/**/*", "/.idea/**/*", "/colored-diff.iml"]
14+
15+
[badges]
16+
is-it-maintained-issue-resolution = { repository = "https://github.com/CAD97/colored-diff" }
17+
is-it-maintained-open-issues = { repository = "https://github.com/CAD97/colored-diff" }
18+
maintanace = { status = "passively-maintained" }
19+
20+
[dependencies]
21+
difference = "2.0.0"
22+
ansi_term = "0.11.0"
23+
itertools = { version = "0.7.8", default-features = false }

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Christopher Durham (aka CAD97)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# colored-diff
2+
3+
Show colored differences between source strings!
4+
5+
Inspired by / extracted from [pretty-assertions](https://github.com/colin-kiegel/rust-pretty-assertions)
6+
and [difference's github-style example](https://github.com/johannhof/difference.rs/blob/master/examples/github-style.rs)
7+
8+
Powershell:
9+
![Powershell Example](.github/example-ps.png)
10+
11+
Command Prompt:
12+
![Command Prompt Example](.github/example-cmd.png)
13+
14+
(Now accepting PRs for a macOS Terminal and/or Ubuntu (whatever console window) examples!)
15+
16+
[Poem Example](examples/poem.rs):
17+
18+
```rust
19+
let expected = "\
20+
Roses are red, violets are blue,\n\
21+
I wrote this library here,\n\
22+
just for you.\n\
23+
(It's true).\n\
24+
";
25+
let actual = "\
26+
Roses are red, violets are blue,\n\
27+
I wrote this documentation here,\n\
28+
just for you.\n\
29+
(It's quite true).\n\
30+
";
31+
32+
colored_diff::init();
33+
println!("{}", colored_diff::PrettyDifference { expected, actual })
34+
```
35+
36+
[Pretty-Assertions Example](examples/pretty_assertions.rs):
37+
38+
```rust
39+
#[derive(Debug, PartialEq)]
40+
struct Foo {
41+
lorem: &'static str,
42+
ipsum: u32,
43+
dolor: Result<String, String>,
44+
}
45+
46+
let x = Some(Foo { lorem: "Hello World!", ipsum: 42, dolor: Ok("hey".to_string())});
47+
let y = Some(Foo { lorem: "Hello Wrold!", ipsum: 42, dolor: Ok("hey ho!".to_string())});
48+
49+
let x = format!("{:#?}", x);
50+
let y = format!("{:#?}", y);
51+
52+
colored_diff::init();
53+
println!("{}", colored_diff::PrettyDifference { expected: &x, actual: &y })
54+
```

0 commit comments

Comments
 (0)