diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 0649e13..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -## [0.1.0] - 2022-11-28 - -Initial release - - diff --git a/Cargo.toml b/Cargo.toml index e1c7ee2..567915d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = ["ThetaDev"] license = "GPL-3.0" description = "Romanize hiragana, katakana and kanji (Japanese text)" -include = ["src/*", "tests/*", "benches/*", "README.md", "LICENSE"] +include = ["/src", "README.md", "LICENSE"] [workspace] members = [".", "codegen"] @@ -19,7 +19,7 @@ unicode-normalization = "0.1.22" [dev-dependencies] criterion = "0.4.0" -rstest = { version = "0.16.0", default-features = false } +rstest = { version = "0.15.0", default-features = false } [[bench]] name = "kakasi_benchmark" diff --git a/README.md b/README.md index ace1c92..eab96d7 100644 --- a/README.md +++ b/README.md @@ -25,26 +25,6 @@ assert_eq!(kakasi::is_japanese("日本"), IsJapanese::Maybe); assert_eq!(kakasi::is_japanese("ラスト"), IsJapanese::True); ``` -## CLI - -```sh -$ cargo install kakasi - -## Convert to romaji -$ kakasi Hello 日本! -Hello nihon ! - -## Convert to hiragana -$ kakasi -k Hello 日本! -Hello にほん! - -## Read from file -$ kakasi -f rust_article.txt - -## Read from STDIN -$ echo "Hello 日本" | kakasi -``` - ## Performance Time to convert a 100KB test file using the CLI: diff --git a/cliff.toml b/cliff.toml deleted file mode 100644 index a297248..0000000 --- a/cliff.toml +++ /dev/null @@ -1,70 +0,0 @@ -# configuration file for git-cliff (0.1.0) - -[changelog] -# changelog header -header = """ -# Changelog\n -All notable changes to this project will be documented in this file.\n -""" -# template for the changelog body -# https://tera.netlify.app/docs/#introduction -body = """ -{% if version %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | upper_first }} - {% for commit in commits %} - - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ - {% endfor %} -{% endfor %}\n -""" -# remove the leading and trailing whitespace from the template -trim = true -# changelog footer -footer = """ - -""" - -[git] -# parse the commits based on https://www.conventionalcommits.org -conventional_commits = true -# filter out the commits that are not conventional -filter_unconventional = true -# process each line of a commit as an individual commit -split_commits = true -# regex for preprocessing the commit messages -commit_preprocessors = [ - { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, -] -# regex for parsing and grouping commits -commit_parsers = [ - { message = "^feat", group = "Features"}, - { message = "^fix", group = "Bug Fixes"}, - { message = "^doc", group = "Documentation"}, - { message = "^perf", group = "Performance"}, - { message = "^refactor", group = "Refactor"}, - { message = "^style", group = "Styling"}, - { message = "^test", group = "Testing"}, - { message = "^chore\\(release\\): prepare for", skip = true}, - { message = "^chore", group = "Miscellaneous Tasks"}, - { body = ".*security", group = "Security"}, -] -# protect breaking changes from being skipped due to matching a skipping commit_parser -protect_breaking_commits = false -# filter out the commits that are not matched by commit parsers -filter_commits = false -# glob pattern for matching git tags -tag_pattern = "v[0-9]*" -# regex for skipping tags -skip_tags = "" -# regex for ignoring tags -ignore_tags = "" -# sort the tags chronologically -date_order = false -# sort the commits inside sections by oldest/newest order -sort_commits = "oldest" -# limit the number of commits included in the changelog. -# limit_commits = 42 diff --git a/src/main.rs b/src/main.rs index e333aad..cfc500a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,23 +17,20 @@ fn main() { // Parse commandline arguments let mut hira = false; let mut path = None; - let mut txt = String::new(); let mut args = std::env::args(); - let mut after_opts = false; let pname = args.next().unwrap_or_else(|| "kakasi".to_owned()); - while let Some(a) = args.next() { - if !after_opts && a.starts_with('-') { + for a in args { + if a.starts_with('-') { if a == "-h" || a == "--help" { println!( r#"Transliterate hiragana, katakana and kanji (Japanese text) into romaji (Latin alphabet). -Usage: {} [OPTION] [Japanese text] +Usage: {} [OPTION] [FILE] -With no file or text given, kakasi reads from STDIN. +With no FILE, read standard input. Options: - -f Read from text file -k Transliterate to hiragana instead of romaji -h show this help page"#, pname @@ -41,23 +38,11 @@ Options: return; } else if a == "-k" { hira = true; - } else if a == "-f" { - match args.next() { - Some(p) => path = Some(PathBuf::from(p)), - None => { - eprintln!("no file path given"); - std::process::exit(2); - } - } } else { continue; } - } else { - after_opts = true; - if !txt.is_empty() { - txt.push(' '); - } - txt += &a; + } else if path.is_none() { + path = Some(PathBuf::from(a)); } } @@ -75,15 +60,9 @@ Options: .flatten() .for_each(|l| convert_line(&l, hira)); } - None => { - if txt.is_empty() { - std::io::stdin() - .lines() - .flatten() - .for_each(|l| convert_line(&l, hira)) - } else { - txt.lines().for_each(|l| convert_line(l, hira)); - } - } + None => std::io::stdin() + .lines() + .flatten() + .for_each(|l| convert_line(&l, hira)), }; }