Skip to content

Commit

Permalink
added --no-color option (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkwalExe authored Mar 31, 2022
1 parent acfa814 commit 9f54c80
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 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 = "cow-translator"
version = "0.2.2"
version = "0.3.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
Binary file modified images/usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn add_to_string_like_binary(input: String, to_add: i32) -> String {
fn main() {
let mut command = "to_cow"; // the command to execute : to_cow, to_text, help, version
let mut input = String::from(""); // the input string to convert
let mut color = true;

let chars = vec![
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
Expand All @@ -125,6 +126,10 @@ fn main() {
command = "to_text"; // set the command to : convert cow language to text
args.remove(0);
}
"-nc" | "--no-color" => {
color = false;
args.remove(0);
}
"--" => {
args.remove(0);
input = args.join(" ").to_string(); // everything after the "--" is the input and isn't parsed
Expand Down Expand Up @@ -176,6 +181,10 @@ fn main() {
"\t{}--to-text, -t: {}Converts cow to text{}",
MAGENTA, YELLOW, RESET
);
println!(
"\t{}--no-color, -nc: {}Dont color the output{}",
MAGENTA, YELLOW, RESET
);
println!(
"\t{}-- [text] : {}Specify the text to convert{}",
MAGENTA, YELLOW, RESET
Expand Down Expand Up @@ -244,7 +253,8 @@ fn main() {
input_as_moos.push_str(&format!("{} ", c_as_moo)); // add the moo to the input_as_moos string
}

println!("\n{}{}", MAGENTA, input_as_moos); // print the result, the input converted to moos
println!("\n{}{}", if color { MAGENTA } else { "" }, input_as_moos);
// print the result, the input converted to moos
}
"to_text" => {
if input.is_empty() {
Expand Down Expand Up @@ -287,7 +297,8 @@ fn main() {
input_as_text.push(*moo_as_char); // add the character to the input_as_text string
}

println!("\n{}{}", MAGENTA, input_as_text); // print the result, the moos converted to text
println!("\n{}{}", if color { MAGENTA } else { "" }, input_as_text);
// print the result, the moos converted to text
}
_ => {}
}
Expand Down

0 comments on commit 9f54c80

Please sign in to comment.