Skip to content

Commit

Permalink
Fix lack of newline
Browse files Browse the repository at this point in the history
  • Loading branch information
kogai committed May 25, 2018
1 parent 535dfa7 commit 39632ad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 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 = "trs"
version = "0.5.2"
version = "0.5.3"
authors = ["shinichi kogai <kogai0121@gmail.com>"]
categories = ["command-line-utilities"]

Expand Down
53 changes: 22 additions & 31 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ fn translate_between(
}

fn run() {
let arg_of_dictionary = Arg::with_name("dictionary")
.index(1)
.takes_value(true)
.multiple(true);

let arg_of_to = Arg::with_name("to-target-language")
.index(1)
.takes_value(true)
.multiple(true);

let arg_of_from = Arg::with_name("from-target-language")
.index(1)
.takes_value(true)
.multiple(true);

let matches = App::new(crate_name!())
.version(crate_version!())
.about("CLI tool for English learners")
Expand All @@ -75,22 +60,28 @@ fn run() {
.subcommands(vec![
SubCommand::with_name("dictionary")
.about("See formal English definition of the words")
.arg(&arg_of_dictionary),
SubCommand::with_name("d")
.about("Alias for dictionary")
.arg(arg_of_dictionary),
.arg(
Arg::with_name("dictionary")
.index(1)
.takes_value(true)
.multiple(true),
),
SubCommand::with_name("from")
.about("Set the words that translate from target language to english")
.arg(&arg_of_from),
SubCommand::with_name("f")
.about("Alias for from")
.arg(arg_of_from),
.arg(
Arg::with_name("from-target-language")
.index(1)
.takes_value(true)
.multiple(true),
),
SubCommand::with_name("to")
.about("Set the words that translate to")
.arg(&arg_of_to),
SubCommand::with_name("t")
.about("Alias for to")
.arg(arg_of_to),
.arg(
Arg::with_name("to-target-language")
.index(1)
.takes_value(true)
.multiple(true),
),
])
.get_matches();

Expand All @@ -116,7 +107,7 @@ fn run() {
};

let result = match matches.subcommand() {
("dictionary", Some(cmd)) | ("d", Some(cmd)) => {
("dictionary", Some(cmd)) => {
let namespace = cache::Namespace::Dictionary;
let query_words = values_t!(cmd.values_of("dictionary"), String).unwrap_or(vec![]);
println!("{:#?}", query_words);
Expand All @@ -131,7 +122,7 @@ fn run() {
};
definitions
}
("to", Some(cmd)) | ("t", Some(cmd)) => {
("to", Some(cmd)) => {
let query_words =
values_t!(cmd.values_of("to-target-language"), String).unwrap_or(vec![]);
let target_language = default_language;
Expand All @@ -142,7 +133,7 @@ fn run() {
&mut fs_cache,
)
}
("from", Some(cmd)) | ("f", Some(cmd)) => {
("from", Some(cmd)) => {
let query_words =
values_t!(cmd.values_of("from-target-language"), String).unwrap_or(vec![]);
let target_language = "en".to_owned();
Expand All @@ -156,7 +147,7 @@ fn run() {
_ => unreachable!(),
};

let _ = io::stdout().write(result.as_bytes());
let _ = io::stdout().write(format!("{}\n", result).as_bytes());
let _ = span_of("garbage_collect", || fs_cache.garbage_colloect());
}

Expand Down

0 comments on commit 39632ad

Please sign in to comment.