Crates.io | random_name_generator |
lib.rs | random_name_generator |
version | 0.3.6 |
source | src |
created_at | 2020-09-08 17:39:03.270303 |
updated_at | 2023-09-16 19:08:11.080698 |
description | Random Name Generator |
homepage | https://github.com/folkengine/random_name_generator_rs |
repository | https://github.com/folkengine/random_name_generator_rs.git |
max_upload_size | |
id | 286212 |
size | 116,003 |
This is a rust port of the Ruby port of the Java Random Name Generator library.
It generates it's results based upon which language file is specified. Currently, the following are supported in both English and Russian:
Thanks to Zhumatiy Sergey, for his contribution of the Russian language files, originally in the Ruby version of this library!
The following are in progress:
use rnglib::{RNG, Language};
fn main() {
let rng = RNG::try_from(&Language::Elven).unwrap();
let first_name = rng.generate_name();
let last_name = rng.generate_name();
println!("{}: {} {}", rng.name, first_name, last_name)
}
It is possible to control the number of syllables for a generated name:
use rnglib::{RNG, Language};
fn main() {
let rng = RNG::try_from(&Language::Fantasy).unwrap();
let name = rng.generate_name_by_count(3);
println!("{}: {}", rng.name, name)
}
One can also pass in custom language files:
use rnglib::{RNG};
fn main() {
let rng = RNG::new_from_file("src/languages/Test-tiny.txt").unwrap();
let name = rng.generate_name();
println!("{}: {}", rng.name, name)
}
To get information about the available options, run help.
Using cargo:
$> cargo run -- --help
Random Name Generator
Usage: rng [OPTIONS]
Options:
-d, --demonic
-e, --elven
-f, --fantasy
-g, --goblin
-r, --roman
-c, --curse [UNDER CONSTRUCTION]
-x, --flipmode Flipmode is the greatest! (Random language)
--russian Use Russian language file, if available
--short Creates shorter names
--raw <FILE> Reads in a raw language file
-n, --number <number> Number of names created. [default: 2]
-h, --help Print help
-V, --version Print version
or from the binary:
$> rng --help
Passing in one of the language flags will generate a name using that Language's source file.
From cargo:
$> cargo run -- -g
Goblin: zradogul bargodul
It also now supports Russian language files:
❯ cargo run -- --roman --russian
Римский: Дафрибуцио Дубенус
❯ cargo run -- --goblin --russian
Гоблин: Краог Зрашагул
❯ cargo run -- --fantasy --russian
Фантазия: Валорнен Гарлакот
❯ cargo run -- --elven --russian
Эльфийский: Латэнаэлмасан Шелиан
From the binary:
$> rng -e
Elven: daedar latherdre