-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e498f2
commit 3aa0722
Showing
5 changed files
with
124 additions
and
8 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,2 +1,15 @@ | ||
# rmdup | ||
Simple tool for removing duplicate files | ||
Simple tool for removing duplicate files | ||
|
||
# Usage | ||
```rmdup <file.txt>``` | ||
You just pass a file and it will scan the Current Working Directory for files that have the same [BLAKE3](https://github.com/BLAKE3-team/BLAKE3) hash. | ||
|
||
This tool is likely to get even more functionality in the future. If you'd like to have a feature added, just open a new Issue. | ||
|
||
# Installation | ||
## Cargo | ||
```cargo install rmdup``` | ||
|
||
## GitHub | ||
There are also precompiled binaries on GitHub. Just go to the [Release](https://github.com/Stridsvagn69420/rmdup/releases) Page and download the standalone binary for your platform. |
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,44 @@ | ||
use std::process::Command; | ||
use std::path::Path; | ||
use std::io; | ||
use std::env; | ||
|
||
fn main() { | ||
// ----- Target Triple ----- | ||
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap()); | ||
|
||
// ----- Rust Version ----- | ||
println!("cargo:rustc-env=CARGO_VERSION={}", version("cargo")); | ||
println!("cargo:rustc-env=RUSTC_VERSION={}", version("rustc")); | ||
|
||
// ----- Git Data ----- | ||
if Path::new(".git").exists() { | ||
// Get the current branch name | ||
match git(&["symbolic-ref", "--short", "HEAD"]) { | ||
Ok(branch) => println!("cargo:rustc-env=GIT_BRANCH_TAG={}", branch), | ||
// Try to get tag if you're not on a branch | ||
Err(_) => { | ||
if let Ok(tag) = git(&["describe", "--tags", "--exact-match"]) { | ||
println!("cargo:rustc-env=GIT_BRANCH_TAG={}", tag) | ||
} | ||
} | ||
} | ||
// Get Latest Commit Hash | ||
if let Ok(hash) = git(&["rev-parse", "--short", "HEAD"]) { | ||
println!("cargo:rustc-env=GIT_HASH={}", hash); | ||
}; | ||
} | ||
} | ||
|
||
fn git(args: &[&str]) -> io::Result<String> { | ||
let output = Command::new("git") | ||
.args(args) | ||
.output()?; | ||
Ok(String::from_utf8(output.stdout).unwrap()) | ||
} | ||
|
||
fn version(name: &str) -> String { | ||
let output = Command::new(name).arg("--version").output().unwrap(); | ||
let raw = String::from_utf8(output.stdout).unwrap(); | ||
raw.replace(&format!("{} ", name), "") | ||
} |
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,15 +1,62 @@ | ||
use kagero::printer::{Colors, Printer}; | ||
use std::env::consts::{ARCH, OS}; | ||
|
||
const VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
const NAME: &str = env!("CARGO_PKG_NAME"); | ||
const REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY"); | ||
const DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); | ||
const TARGET: &str = env!("TARGET"); | ||
const CARGO_VERSION: &str = env!("CARGO_VERSION"); | ||
const RUSTC_VERSION: &str = env!("RUSTC_VERSION"); | ||
static GIT_BRANCH_TAG: Option<&str> = option_env!("GIT_BRANCH_TAG"); | ||
static GIT_HASH: Option<&str> = option_env!("GIT_HASH"); | ||
|
||
/// Help Message | ||
/// | ||
/// Displays a help message for using this tool. | ||
pub(crate) fn help_message(p: &mut Printer) { | ||
p.writeln("Help Message still WIP"); | ||
// Usage | ||
p.print("USAGE: ", Colors::RedBright).print(NAME, Colors::Red).println(" <FILE>", Colors::Red) | ||
.writeln("") | ||
|
||
// Args | ||
.println("ARGS:", Colors::MagentaBright) | ||
.print("FILE: ", Colors::Magenta).writeln("Path to the file whose duplicates are to be deleted") | ||
.writeln("") | ||
|
||
// Flags | ||
.println("FLAGS:", Colors::CyanBright) | ||
.print("-V, --version: ", Colors::Cyan).writeln("Prints metadata of this tool") | ||
.print("-h, --help:", Colors::Cyan).writeln("Prints this help message"); | ||
|
||
} | ||
|
||
/// Version Message | ||
/// | ||
/// Prints metadata like authors and version of the program. | ||
/// Prints metadata of the program. | ||
pub(crate) fn version(p: &mut Printer) { | ||
p.writeln("Version Message still WIP"); | ||
// Name and Description | ||
p.print(NAME, Colors::RedBright) | ||
.print(" - ", Colors::RedBright) | ||
.println(DESCRIPTION, Colors::RedBright) | ||
|
||
// Version | ||
.print("Version: ", Colors::Magenta) | ||
.write("v").write(VERSION).write("@").write(OS).write("-").writeln(ARCH); // format!("v{VERSION}@{OS}-{ARCH}") | ||
|
||
// Repository and Git | ||
p.print("Repository: ", Colors::Magenta).writeln(REPOSITORY) | ||
.print("Build: ", Colors::Magenta); | ||
if GIT_BRANCH_TAG.is_some() && GIT_HASH.is_some() { | ||
p.write(GIT_HASH.unwrap()) | ||
.write("@") | ||
.writeln(GIT_BRANCH_TAG.unwrap()); | ||
} else { | ||
p.write(VERSION).writeln("@crates.io"); | ||
} | ||
|
||
// Rust | ||
p.print("Target: ", Colors::Blue).writeln(TARGET) | ||
.print("Rust: ", Colors::Blue).writeln(RUSTC_VERSION) | ||
.print("Cargo: ", Colors::Blue).writeln(CARGO_VERSION); | ||
} |