Compare commits

..

No commits in common. "fe6cd2c83ff8b6bb8a6f278cbe32cbf78322e5a2" and "903ea0b67af81b4ce8aca30707bbcad08f737569" have entirely different histories.

5 changed files with 12 additions and 132 deletions

View file

@ -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
<!-- generated by git-cliff -->

View file

@ -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"

View file

@ -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:

View file

@ -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 = """
<!-- generated by git-cliff -->
"""
[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

View file

@ -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 <FILE> 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()
None => std::io::stdin()
.lines()
.flatten()
.for_each(|l| convert_line(&l, hira))
} else {
txt.lines().for_each(|l| convert_line(l, hira));
}
}
.for_each(|l| convert_line(&l, hira)),
};
}