Skip to content

Commit

Permalink
v0.1.3 minor path; changed styles, changed lib definition
Browse files Browse the repository at this point in the history
  • Loading branch information
famedaxolotl committed Jul 17, 2024
1 parent 7e3f1c8 commit cfe7d99
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "terminal-dictionary"
version = "0.1.2"
version = "0.1.3"
authors = ["Axolotl [email protected]"]
edition = "2021"
description = "Simple Dictionary on the terminal"
Expand Down
17 changes: 8 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,20 @@ impl QueryType{
if let Some(def_word) = def_matches.get_one::<String>("def_word") {
query_type = QueryType::Dictionary(def_word.to_string());
} else {
return Err("Invalid word entered for def".into());
return Err("Invalid word entered for `def`".into());
}
} else if let Some(thes_matches) = matches.subcommand_matches("thes") {
if let Some(thes_word) = thes_matches.get_one::<String>("thes_word") {
query_type = QueryType::Thesaurus(thes_word.to_string());
} else {
return Err("Invalid word entered for thes".into());
return Err("Invalid word entered for `thes`".into());
}
} else {
return Err("No subcommand was used".into());
}
Ok(query_type)
}
}

// these are the structs the api response deserializes into
// '->' means 'contains'
// Wordinfo -> Singlemeaning -> Definition
Expand All @@ -73,10 +72,10 @@ pub struct WordInfo{
impl WordInfo{
pub fn dictionary(&self){
for meaning in self.meanings.iter(){
println!("{}-----------{}", self.word.to_uppercase().green(), meaning.part_of_speech.to_ascii_uppercase().green());
println!("{}-----------{}", self.word.to_uppercase().green().bold(), meaning.part_of_speech.to_ascii_uppercase().italic().green());
for def_obj in meaning.definitions.iter(){
println!("{}", def_obj.definition.bold());
println!("Example: {}\n", def_obj.example.clone().unwrap_or("N/A".to_string()).blue());
println!("Example: {}\n", def_obj.example.clone().unwrap_or("N/A".to_string()).blue().italic());
}
}
}
Expand All @@ -95,9 +94,9 @@ impl WordInfo{
}
}

println!("Synonyms and antonyms for {}", self.word.to_uppercase().green());
println!("Synonyms: {}", syn_list);
println!("Antonyms: {}", ant_list);
println!("Synonyms and antonyms for {}", self.word.to_uppercase().bold().italic().green());
println!("Synonyms: {}", syn_list.bold());
println!("Antonyms: {}", ant_list.bold());
}
}

Expand All @@ -124,4 +123,4 @@ pub fn get_json(search_word: &String) -> Result<WordInfo, Box<dyn std::error::Er
let word_info: Vec<WordInfo> = serde_json::from_str(&res)?;

Ok(word_info.first().unwrap().clone())
}
}
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(special_module_name)]
pub mod lib;
use lib::{get_json, QueryType};
use terminal_dictionary::{get_json, QueryType};
use std::process;

fn main() {
Expand Down

0 comments on commit cfe7d99

Please sign in to comment.