diff --git a/Cargo.toml b/Cargo.toml index 2b808ee..725dcc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,9 +18,9 @@ description = "Look up words via online dictionaries" # Will automatically link to the corresponding docs.rs page if not given. # Must set it because docs.rs only render libraries. # ref: https://doc.rust-lang.org/cargo/reference/manifest.html#the-documentation-field -#documentation = "" -#homepage = "" -#repository = "" +documentation = "https://github.com/zdict/rust-zdict" +homepage = "https://github.com/zdict/rust-zdict" +repository = "https://github.com/zdict/rust-zdict" [dependencies] diff --git a/README.md b/README.md index a32f48a..7510990 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,41 @@ # zdict A Rust version of [zdict](https://github.com/zdict/zdict). + + +## Install + +```console +cargo install --git https://github.com/zdict/rust-zdict +``` + + +## Usage + +``` +zdict + +USAGE: + zd [FLAGS] [OPTIONS] ... + zd + +ARGS: + ... Search translation of words + +FLAGS: + -d, --disable-db-cache Temporarily not using the result from db cache. (still save the result + into db) + -h, --help Print help information + --show-provider Show dictionary provider + --show-url Show URL + -v, --verbose Use verbose output + -V, --version Print version information + +OPTIONS: + --dict Choose the dictionary [possible values: yahoo, urban, all] + +SUBCOMMANDS: + dicts Show currently supported dictionaries +``` + +![](https://user-images.githubusercontent.com/829295/137491540-e1db8ba4-0129-4d6e-af82-21b5399cfbb4.png) diff --git a/src/dict.rs b/src/dict.rs index 07e1a67..d34a54c 100644 --- a/src/dict.rs +++ b/src/dict.rs @@ -113,17 +113,20 @@ fn lookup(word: &str, opts: &Opts, db_cache: Option<&Cache>) { } fn show_failure(err: BoxError, word: &str) { - let repo = "https://github.com/zdict/rust-zdict/"; - let issues = format!("{}issues", repo); println!("\ {err:?}\n\ {err}\n\ ================================================================================\n\ - Entryionary: {} ({})\n\ - Word: '{}'\n\ + Entryionary: {dict_title} ({dict_name})\n\ + Word: '{word}'\n\ ================================================================================\n\ \n\ Houston, we got a problem 😢\n\ - Please report the error message above to {}\ - ", Entry::DICT.title, Entry::DICT.name, word, issues, err=err); + Please report the error message above to {issues}", + dict_title = Entry::DICT.title, + dict_name = Entry::DICT.name, + word = word, + issues = format!("{}/issues", env!("CARGO_PKG_REPOSITORY")), + err = err + ); }