Update to adjective_adjective_animal
This commit is contained in:
parent
843ca9c9b2
commit
240308389c
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
target
|
||||
/Cargo.lock
|
||||
Cargo.lock
|
||||
cli/Cargo.lock
|
||||
.idea
|
12
.travis.yml
12
.travis.yml
@ -14,15 +14,3 @@ script:
|
||||
- cargo test --verbose
|
||||
- cargo doc --verbose
|
||||
- "(cd cli && cargo build --verbose)"
|
||||
|
||||
after_success: |
|
||||
[ $TRAVIS_BRANCH = master ] &&
|
||||
[ $TRAVIS_PULL_REQUEST = false ] &&
|
||||
echo '<meta http-equiv=refresh content=0;url=names/index.html>' > target/doc/index.html &&
|
||||
pip install ghp-import --user $USER &&
|
||||
$HOME/.local/bin/ghp-import -n target/doc &&
|
||||
git push -fq https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
|
||||
|
||||
env:
|
||||
global:
|
||||
secure: B6wLsR6HDHo/VhjM2azghFJ66PZIyNyDDfly4FT0P9UmmHEwdM1mk3YWlNx9NT2s8jp9I+wChYehPeWjCTd8QHVyYgvKS0FdHFNZDMTBE306q6fjQgMxLXsLINkc4U2+b3JUjx/lyAzvVjNIO53KXq+ydWXbrHEWIKTvzkm5o7zNNJQ2ZHMQm6SlJVY++x439PMMPTp9KZWYcwroNrpf+cUdMbvVhF7DA/5SysJpXDL4Y7KC7kzyOXdZPOhW4qK1FNKCmIB7t1OwgMXS8/b260nvAKPRUCA7IodRdogBieDEZ3CW5qhiT/kUgWC3aRgpS9nhiv3YLbArR5bv3IO2s8t2w34A4TJl5NcTMzW2PZQSniGxhX4CA2gQJHa3QlVxZkOXDATJkZeqtoB7vY6Amf/Gv8pZoMnz5OlKqbkAy8iRhtgTczEfG91C6jxY5FLixo/g3ccZoOK5Fy9O+CI8VNp7DAlMSK2+NZVdIDNhuRgGFxT6HMQCeo65tgdWAwIigR6D58cO4sLbh8TvQL7vzNOtfvZ8IZKVSIOMb4KDxAzKShq3m3P7XOWQUt2DuhpYiT4PdcyVqoQUrUmSp1M6mulglefSqVuyv4h7vUAGzmLgcO4lpZy69452JfvphRAYOniWvXZA5HKCVWZCjBy9H+/szQqeJ445pVlsZMUQAUQ=
|
||||
|
29
CHANGELOG.md
29
CHANGELOG.md
@ -1,30 +1,3 @@
|
||||
## 0.11.0 / 2016-04-29
|
||||
|
||||
### Breaking API changes
|
||||
|
||||
* Move adjectives const to `names::ADJECTIVES`. ([@fnichol][])
|
||||
* Move nouns const to `names::NOUNS`. ([@fnichol][])
|
||||
|
||||
### Improvements
|
||||
|
||||
* (cli) Add color and suggestions features. ([@fnichol][])
|
||||
* Inline adjective and noun data from plaintext files. ([@fnichol][])
|
||||
|
||||
|
||||
## 0.10.0 / 2015-11-01
|
||||
|
||||
### Breaking API changes
|
||||
|
||||
* Use `Default` trait for Generator & Name types. ([@fnichol][])
|
||||
|
||||
### Improvements
|
||||
|
||||
* (cli) Update usage output. ([@fnichol][])
|
||||
|
||||
|
||||
## 0.9.0 / 2015-09-15
|
||||
## 0.1.0 / 2018-10-06
|
||||
|
||||
The initial release.
|
||||
|
||||
<!--- The following link definition list is generated by PimpMyChangelog --->
|
||||
[@fnichol]: https://github.com/fnichol
|
||||
|
22
Cargo.toml
22
Cargo.toml
@ -1,23 +1,23 @@
|
||||
[package]
|
||||
name = "names"
|
||||
version = "0.11.0"
|
||||
authors = ["Fletcher Nichol <fnichol@nichol.ca>"]
|
||||
name = "adjective_adjective_animal"
|
||||
version = "0.1.0"
|
||||
authors = ["Travis Burtrum <admin.github@moparisthebest.com>", "Fletcher Nichol <fnichol@nichol.ca>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
documentation = "http://fnichol.github.io/names/names/"
|
||||
repository = "https://github.com/fnichol/names.git"
|
||||
homepage = "https://github.com/fnichol/names.git"
|
||||
keywords = ["name", "random"]
|
||||
documentation = "https://github.com/moparisthebest/adjective-adjective-animal"
|
||||
repository = "https://github.com/moparisthebest/adjective-adjective-animal.git"
|
||||
homepage = "https://github.com/moparisthebest/adjective-adjective-animal"
|
||||
keywords = ["name", "random", "adjective", "animal"]
|
||||
description = """
|
||||
A library to generate random name strings suitable for use in container
|
||||
instances, project names, application instances, etc.
|
||||
A library to generate suitably random and reasonably unique human readable (and fairly adorable) ids,
|
||||
ala GiphyCat
|
||||
"""
|
||||
exclude = ["cli"]
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "names"
|
||||
name = "adjective_adjective_animal"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.3.0"
|
||||
rand = "0.5.4"
|
||||
|
@ -1,3 +1,4 @@
|
||||
Copyright (c) 2018 Travis Burtrum
|
||||
Copyright (c) 2015 Fletcher Nichol
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
|
59
README.md
59
README.md
@ -1,28 +1,29 @@
|
||||
# names
|
||||
# adjective_adjective_animal
|
||||
|
||||
[![Build Status](https://travis-ci.org/fnichol/names.svg?branch=master)](https://travis-ci.org/fnichol/names) [![](http://meritbadge.herokuapp.com/names)](https://crates.io/crates/names) [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/fnichol/names/blob/master/LICENSE-MIT)
|
||||
[![Build Status](https://travis-ci.org/moparisthebest/adjective-adjective-animal.svg?branch=master)](https://travis-ci.org/moparisthebest/adjective-adjective-animal) [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/moparisthebest/adjective-adjective-animal/blob/master/LICENSE-MIT)
|
||||
|
||||
Random name generator for Rust
|
||||
Rust library to generate suitably random and reasonably unique human readable (and fairly adorable) ids,
|
||||
ala GiphyCat
|
||||
|
||||
* Crate: https://crates.io/crates/names
|
||||
* Documentation http://fnichol.github.io/names/names/
|
||||
* Source Code: https://github.com/fnichol/names
|
||||
* Crate: https://crates.io/crates/adjective_adjective_animal
|
||||
* Documentation https://docs.rs/crate/adjective_adjective_animal
|
||||
* Source Code: https://github.com/moparisthebest/adjective-adjective-animal
|
||||
|
||||
## Usage
|
||||
|
||||
This crate is [on crates.io](https://crates.io/crates/names) and can be
|
||||
used by adding `names` to your dependencies in your project's `Cargo.toml`
|
||||
This crate is [on crates.io](https://crates.io/crates/adjective_adjective_animal) and can be
|
||||
used by adding `adjective_adjective_animal` to your dependencies in your project's `Cargo.toml`
|
||||
file:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
names = "0.10.0"
|
||||
adjective_adjective_animal = "0.1.0"
|
||||
```
|
||||
|
||||
and this to your crate root:
|
||||
|
||||
```rust
|
||||
extern crate names;
|
||||
extern crate adjective_adjective_animal;
|
||||
```
|
||||
|
||||
### Example: Painless defaults
|
||||
@ -31,43 +32,37 @@ The easiest way to get started is to use the default `Generator` to return
|
||||
a name:
|
||||
|
||||
```rust
|
||||
use names::{Generator, Name};
|
||||
use adjective_adjective_animal::Generator;
|
||||
|
||||
fn main() {
|
||||
let mut generator = Generator::with_naming(Name::Plain);
|
||||
|
||||
let mut generator = Generator::default();
|
||||
println!("Your project is: {}", generator.next().unwrap());
|
||||
// #=> "Your project is: rusty-nail"
|
||||
// #=> "Your project is: IndustrialSecretiveSwan"
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
If more randomness is required, you can generate a name with a trailing
|
||||
4-digit number:
|
||||
|
||||
```rust
|
||||
use names::{Generator, Name};
|
||||
|
||||
fn main() {
|
||||
let mut generator = Generator::with_naming(Name::Numbered);
|
||||
println!("Your project is: {}", generator.next().unwrap());
|
||||
// #=> "Your project is: pushy-pencil-5602"
|
||||
}
|
||||
```
|
||||
|
||||
# Example: with custom dictionaries
|
||||
|
||||
If you would rather supply your own custom adjective and noun word lists,
|
||||
If you would rather supply your own custom adjective and animal word lists,
|
||||
you can provide your own by supplying 2 string slices. For example,
|
||||
this returns only one result:
|
||||
|
||||
```
|
||||
use names::{Generator, Name};
|
||||
use adjective_adjective_animal::Generator;
|
||||
|
||||
fn main() {
|
||||
let adjectives = &["imaginary"];
|
||||
let nouns = &["roll"];
|
||||
let mut generator = Generator::new(adjectives, nouns, Name::Plain);
|
||||
let adjectives = &["Imaginary"];
|
||||
let animals = &["Bear"];
|
||||
let mut generator = Generator::new(adjectives, animals);
|
||||
|
||||
assert_eq!("imaginary-roll", generator.next().unwrap());
|
||||
assert_eq!("ImaginaryImaginaryBear", generator.next().unwrap());
|
||||
}
|
||||
```
|
||||
|
||||
# Credits
|
||||
* rust's [names](https://github.com/fnichol/names) crate, which this is forked from
|
||||
* npm's [adjective-adjective-animal](https://github.com/a-type/adjective-adjective-animal) for lists
|
||||
* `curl 'https://raw.githubusercontent.com/a-type/adjective-adjective-animal/master/lib/lists/animals.js' | grep -Eo '"[^"]+"' | tr -d '"' | tr '[:upper:]' '[:lower:]' | sed 's/.*/\u&/' | sort | uniq > animals.txt`
|
||||
* `curl 'https://raw.githubusercontent.com/a-type/adjective-adjective-animal/master/lib/lists/adjectives.js' | grep -Eo '"[^"]+"' | tr -d '"' | tr '[:upper:]' '[:lower:]' | sed 's/.*/\u&/' | sort | uniq > adjectives.txt`
|
||||
|
4
build.rs
4
build.rs
@ -7,8 +7,8 @@ use std::path::Path;
|
||||
fn main() {
|
||||
generate(Path::new("data").join("adjectives.txt").as_path(),
|
||||
Path::new(&env::var("OUT_DIR").unwrap()).join("adjectives.rs").as_path());
|
||||
generate(Path::new("data").join("nouns.txt").as_path(),
|
||||
Path::new(&env::var("OUT_DIR").unwrap()).join("nouns.rs").as_path());
|
||||
generate(Path::new("data").join("animals.txt").as_path(),
|
||||
Path::new(&env::var("OUT_DIR").unwrap()).join("animals.rs").as_path());
|
||||
}
|
||||
|
||||
fn generate(src_path: &Path, dst_path: &Path) {
|
||||
|
170
cli/Cargo.lock
generated
170
cli/Cargo.lock
generated
@ -1,170 +0,0 @@
|
||||
[root]
|
||||
name = "names-cli"
|
||||
version = "0.11.0"
|
||||
dependencies = [
|
||||
"clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"names 0.11.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.27.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-zircon"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-zircon-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "names"
|
||||
version = "0.11.0"
|
||||
dependencies = [
|
||||
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "redox_termios"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
|
||||
"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860"
|
||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
||||
"checksum clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1b8c532887f1a292d17de05ae858a8fe50a301e196f9ef0ddb7ccd0d1d00f180"
|
||||
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
|
||||
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
|
||||
"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd"
|
||||
"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
|
||||
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
||||
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
|
||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
|
||||
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
|
||||
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
@ -1,21 +1,21 @@
|
||||
[package]
|
||||
name = "names-cli"
|
||||
version = "0.11.0"
|
||||
authors = ["Fletcher Nichol <fnichol@nichol.ca>"]
|
||||
name = "adjective_adjective_animal_cli"
|
||||
version = "0.1.0"
|
||||
authors = ["Travis Burtrum <admin.github@moparisthebest.com>", "Fletcher Nichol <fnichol@nichol.ca>"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/fnichol/names.git"
|
||||
homepage = "https://github.com/fnichol/names.git"
|
||||
repository = "https://github.com/moparisthebest/adjective-adjective-animal.git"
|
||||
homepage = "https://github.com/moparisthebest/adjective-adjective-animal"
|
||||
description = """
|
||||
A program to generate random names that look like 'used-jellyfish'.
|
||||
A program to generate random names that look like 'DeliriousHungryDolphin'.
|
||||
"""
|
||||
|
||||
[[bin]]
|
||||
name = "names"
|
||||
name = "aaa"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies.clap]
|
||||
version = "~2.27"
|
||||
features = [ "suggestions", "color", "unstable" ]
|
||||
|
||||
[dependencies.names]
|
||||
[dependencies.adjective_adjective_animal]
|
||||
path = ".."
|
||||
|
143
cli/README.md
143
cli/README.md
@ -1,156 +1,65 @@
|
||||
# names - cli
|
||||
# aaa - cli
|
||||
|
||||
[![Build Status](https://travis-ci.org/fnichol/names.svg?branch=master)](https://travis-ci.org/fnichol/names) [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/fnichol/names/blob/master/LICENSE-MIT)
|
||||
[![Build Status](https://travis-ci.org/moparisthebest/adjective-adjective-animal.svg?branch=master)](https://travis-ci.org/moparisthebest/adjective-adjective-animal) [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/moparisthebest/adjective-adjective-animal/blob/master/LICENSE-MIT)
|
||||
|
||||
Random name generator tool that gives you Heroku or Docker-style names.
|
||||
Random name generator tool that gives you suitably random and reasonably unique human readable
|
||||
(and fairly adorable) ids, ala GiphyCat
|
||||
|
||||
## Usage
|
||||
|
||||
Simple! Run without any parameters, you get a name:
|
||||
|
||||
```sh
|
||||
> names
|
||||
selfish-change
|
||||
> aaa
|
||||
IndustrialSecretiveSwan
|
||||
```
|
||||
|
||||
Need more? Tell it how many:
|
||||
|
||||
```sh
|
||||
> names 10
|
||||
rustic-flag
|
||||
nondescript-crayon
|
||||
picayune-map
|
||||
elderly-cough
|
||||
skinny-jeans
|
||||
neat-rock
|
||||
aware-sponge
|
||||
psychotic-coast
|
||||
brawny-event
|
||||
tender-oatmeal
|
||||
```
|
||||
|
||||
Not random enough? How about adding a 4-number pad:
|
||||
|
||||
```sh
|
||||
> names --number 5
|
||||
imported-rod-9680
|
||||
thin-position-2344
|
||||
hysterical-women-5647
|
||||
volatile-pen-9210
|
||||
diligent-grip-4520
|
||||
> aaa 10
|
||||
IronfistedSubhexagonalTern
|
||||
HoroscopicDrowsyBlackfish
|
||||
QuarrelsomeDoubtfulCommabutterfly
|
||||
UniqueHurtYaffle
|
||||
GrubbyBoskyIchthyosaurs
|
||||
BolsteredSyntheticTopi
|
||||
PredespondentAssociativeOkapi
|
||||
StereotypedComfortableScaup
|
||||
CuratorialLacklustreWyvern
|
||||
DazedStonyGiantschnauze
|
||||
```
|
||||
|
||||
If you're ever confused, at least there's help:
|
||||
|
||||
```sh
|
||||
> names --help
|
||||
names 0.11.0
|
||||
> aaa --help
|
||||
aaa 0.1.0
|
||||
|
||||
Author: Fletcher Nichol <fnichol@nichol.ca>
|
||||
|
||||
A random name generator with results like `delirious-pail'.
|
||||
Author: Travis Burtrum <admin.github@moparisthebest.com>
|
||||
A random name generator with results like `DeliriousHungryDolphin'.
|
||||
|
||||
USAGE:
|
||||
names [FLAGS] [ARGS]
|
||||
aaa [amount]
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
-n, --number Adds a random number to the name(s)
|
||||
-V, --version Prints version information
|
||||
|
||||
ARGS:
|
||||
[amount] Number of names to generate (default: 1)
|
||||
<amount> Number of names to generate (default: 1)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### GitHub releases
|
||||
|
||||
There are binary builds for Mac OS X (referred to as "Darwin") and Linux (a small, self-contained static binary) available through the project's [GitHub releases](https://github.com/fnichol/names/releases).
|
||||
|
||||
### Docker images
|
||||
|
||||
If Docker is more your speed, there's a speedy teeny tiny image (~1MB) on the Docker hub at [fnichol/names](https://hub.docker.com/r/fnichol/names/). It's pretty easy to get started:
|
||||
|
||||
```sh
|
||||
> docker run fnichol/names 4
|
||||
furtive-polish
|
||||
modern-business
|
||||
alive-sun
|
||||
tremendous-line
|
||||
```
|
||||
|
||||
### Building from source
|
||||
|
||||
If you want (or need) to build the CLI from source, the following should not take too long. Note that you'll need a version of Rust (and Cargo which ships with the Rust distributions) before running:
|
||||
|
||||
```sh
|
||||
> git clone https://github.com/fnichol/names.git
|
||||
> cd names/cli
|
||||
> git clone https://github.com/moparisthebest/adjective-adjective-animal.git
|
||||
> cd adjective-adjective-animal/cli
|
||||
> cargo build --release
|
||||
# test it out
|
||||
> ./target/release/names
|
||||
> ./target/release/aaa
|
||||
```
|
||||
|
||||
#### A static binary on Linux?
|
||||
|
||||
This project was used by its author to experiment with producing static binaries on Linux from a Rust project that has no external dependencies. This was done using a special build of Rust that supports the [musl](http://www.musl-libc.org/) libc project, available via the [fnichol/rust:1.8.0-musl](https://hub.docker.com/r/fnichol/rust/) Docker image. Here's an example building the CLI to a static ELF binary on Linux:
|
||||
|
||||
```sh
|
||||
> git clone https://github.com/fnichol/names.git
|
||||
> cd names
|
||||
> docker run --rm -ti -v `pwd`:/src -w /src/cli fnichol/rust:1.8.0-musl \
|
||||
cargo build --release --target=x86_64-unknown-linux-musl
|
||||
|
||||
> docker run --rm -ti -v `pwd`:/src fnichol/rust:1.8.0-musl \
|
||||
du -h ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
1.5M ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
|
||||
> docker run --rm -ti -v `pwd`:/src fnichol/rust:1.8.0-musl \
|
||||
ldd ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
not a dynamic executable
|
||||
|
||||
> docker run --rm -ti -v `pwd`:/src fnichol/rust:1.8.0-musl \
|
||||
file ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
./cli/target/x86_64-unknown-linux-musl/release/names: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=6ad327ca3a5b21c42fa158832d89f6e9b0fc8e73, not stripped
|
||||
```
|
||||
|
||||
A variant of this approach is used in the [build_linux.sh](https://github.com/fnichol/names/blob/master/cli/scripts/build_linux.sh) script, which additional strips the binary and produces a Zip archive and SHA 256 checksum:
|
||||
|
||||
|
||||
```sh
|
||||
> git clone https://github.com/fnichol/names.git
|
||||
> cd names
|
||||
> ./cli/scripts/build_linux.sh 0.11.0
|
||||
|
||||
> du -h ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
996K ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
|
||||
> file ./cli/target/x86_64-unknown-linux-musl/release/names
|
||||
./cli/target/x86_64-unknown-linux-musl/release/names: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
|
||||
|
||||
> du -csh ./cli/target/names*.zip*
|
||||
396K cli/target/names_0.11.0_linux_x86_64.zip
|
||||
4.0K cli/target/names_0.11.0_linux_x86_64.zip.sha256
|
||||
400K total
|
||||
```
|
||||
|
||||
## User feedback
|
||||
|
||||
### Issues
|
||||
|
||||
If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/fnichol/names/issues).
|
||||
|
||||
### Contributing
|
||||
|
||||
You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
|
||||
|
||||
Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/fnichol/names/issues), especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
|
||||
|
||||
## Authors
|
||||
|
||||
Created and maintained by [Fletcher Nichol](https://github.com/fnichol) (<fnichol@nichol.ca>)
|
||||
|
||||
## License
|
||||
|
||||
MIT (see [LICENSE-MIT](https://github.com/fnichol/names/blob/master/LICENSE-MIT))
|
||||
|
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
if [ -n "${DEBUG:-}" ]; then set -x; fi
|
||||
|
||||
if [ "`uname`" != "Darwin" ]; then
|
||||
echo ">>> $0 must be executed on Darwin platform, aborting"
|
||||
exit 11
|
||||
fi
|
||||
|
||||
VERSION="${1:-${VERSION}}"
|
||||
|
||||
echo "--> Building Darwin release artifact version $VERSION"
|
||||
pushd `dirname $0`/../../
|
||||
PLATFORM="`uname | tr [[:upper:]] [[:lower:]]`_`uname -m`"
|
||||
BIN=target/release/names
|
||||
cd cli
|
||||
cargo build --verbose --release
|
||||
strip "$BIN"
|
||||
ZIPFILE="`pwd`/target/`basename $BIN`_${VERSION}_$PLATFORM.zip"
|
||||
(cd "`dirname $BIN`"; zip -9 "$ZIPFILE" "`basename $BIN`")
|
||||
cd `dirname $ZIPFILE`
|
||||
shasum -a 256 `basename $ZIPFILE` > `basename $ZIPFILE`.sha256
|
||||
popd
|
||||
echo "--> Finished build Darwin release artifact version $VERSION."
|
@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
if [ -n "${DEBUG:-}" ]; then set -x; fi
|
||||
|
||||
if ! command -v docker >/dev/null; then
|
||||
echo ">>> $0 must be executed on a system with Docker installed, aborting"
|
||||
exit 11
|
||||
fi
|
||||
|
||||
on_exit() {
|
||||
if [ -d "${docker_context:-}" ]; then
|
||||
echo "Cleaning up Docker context $docker_context"
|
||||
rm -rf "$docker_context"
|
||||
fi
|
||||
}
|
||||
|
||||
trap on_exit 1 2 3 15 ERR
|
||||
|
||||
VERSION="${1:-${VERSION}}"
|
||||
docker_context="`mktemp -d -t build_docker-XXXX`"
|
||||
repo="fnichol/names"
|
||||
github_repo="https://github.com/$repo/releases/download"
|
||||
|
||||
echo "--> Building Docker release artifact version $VERSION"
|
||||
pushd "$docker_context"
|
||||
curl -fsSLO \
|
||||
"$github_repo/v${VERSION}/names_${VERSION}_linux_x86_64.zip"
|
||||
curl -fsSLO \
|
||||
"$github_repo/v${VERSION}/names_${VERSION}_linux_x86_64.zip.sha256"
|
||||
shasum -a 256 -c names_*.zip.sha256
|
||||
unzip names_*.zip
|
||||
rm -f names_*.zip
|
||||
|
||||
cat <<_DOCKERFILE_ >Dockerfile
|
||||
FROM scratch
|
||||
ADD names /names
|
||||
ENTRYPOINT ["/names"]
|
||||
_DOCKERFILE_
|
||||
|
||||
docker build -t "$repo:$VERSION" .
|
||||
if [ -n "${LATEST:-}" ]; then docker build -t "$repo:latest" .; fi
|
||||
popd
|
||||
echo "--> Finished build Docker release artifact version $VERSION."
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
if [ -n "${DEBUG:-}" ]; then set -x; fi
|
||||
|
||||
if ! command -v docker >/dev/null; then
|
||||
echo ">>> $0 must be executed on a system with Docker installed, aborting"
|
||||
exit 11
|
||||
fi
|
||||
|
||||
VERSION="${1:-${VERSION}}"
|
||||
|
||||
echo "--> Building Linux release artifact version $VERSION"
|
||||
pushd `dirname $0`/../../
|
||||
docker run --rm -v `pwd`:/src -e VERSION=$VERSION fnichol/rust:1.8.0-musl \
|
||||
bash -c 'set -eux
|
||||
apt-get update
|
||||
apt-get install -y zip
|
||||
PLATFORM="`uname | tr [[:upper:]] [[:lower:]]`_`uname -m`"
|
||||
TARGET=x86_64-unknown-linux-musl
|
||||
BIN=target/$TARGET/release/names
|
||||
cd cli
|
||||
cargo build --verbose --release --target=$TARGET
|
||||
strip "$BIN"
|
||||
ZIPFILE="`pwd`/target/`basename $BIN`_${VERSION}_$PLATFORM.zip"
|
||||
(cd "`dirname $BIN`"; zip -9 "$ZIPFILE" "`basename $BIN`")
|
||||
cd `dirname $ZIPFILE`
|
||||
shasum -a 256 `basename $ZIPFILE` > `basename $ZIPFILE`.sha256
|
||||
'
|
||||
popd
|
||||
echo "--> Finished build Linux release artifact version $VERSION."
|
@ -1,31 +1,24 @@
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate names;
|
||||
extern crate adjective_adjective_animal;
|
||||
|
||||
use names::{Generator, Name};
|
||||
use adjective_adjective_animal::Generator;
|
||||
|
||||
fn main() {
|
||||
let (naming, amount) = {
|
||||
let amount = {
|
||||
let app =
|
||||
clap_app!(names =>
|
||||
clap_app!(aaa =>
|
||||
(version: &crate_version!()[..])
|
||||
(author: "\nAuthor: Fletcher Nichol <fnichol@nichol.ca>\n")
|
||||
(about: "A random name generator with results like `delirious-pail'.")
|
||||
(author: "\nAuthor: Travis Burtrum <admin.github@moparisthebest.com>\n")
|
||||
(about: "A random name generator with results like `DeliriousHungryDolphin'.")
|
||||
(@setting ColoredHelp)
|
||||
(@arg amount: "Number of names to generate (default: 1)")
|
||||
(@arg number: -n --number "Adds a random number to the name(s)")
|
||||
);
|
||||
let matches = app.get_matches();
|
||||
let amount = value_t!(matches.value_of("amount"), usize).unwrap_or(1);
|
||||
let naming: Name = if matches.is_present("number") {
|
||||
Name::Numbered
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
(naming, amount)
|
||||
value_t!(matches.value_of("amount"), usize).unwrap_or(1)
|
||||
};
|
||||
|
||||
let mut generator = Generator::with_naming(naming);
|
||||
let mut generator = Generator::default();
|
||||
for _ in 0..amount {
|
||||
println!("{}", generator.next().unwrap());
|
||||
}
|
||||
|
10300
data/adjectives.txt
10300
data/adjectives.txt
File diff suppressed because it is too large
Load Diff
1748
data/animals.txt
Normal file
1748
data/animals.txt
Normal file
File diff suppressed because it is too large
Load Diff
981
data/nouns.txt
981
data/nouns.txt
@ -1,981 +0,0 @@
|
||||
able
|
||||
account
|
||||
achieve
|
||||
achiever
|
||||
acoustics
|
||||
act
|
||||
action
|
||||
activity
|
||||
actor
|
||||
addition
|
||||
adjustment
|
||||
advertisement
|
||||
advice
|
||||
aftermath
|
||||
afternoon
|
||||
afterthought
|
||||
agreement
|
||||
air
|
||||
airplane
|
||||
airport
|
||||
alarm
|
||||
alley
|
||||
amount
|
||||
amusement
|
||||
anger
|
||||
angle
|
||||
animal
|
||||
answer
|
||||
ant
|
||||
ants
|
||||
apparatus
|
||||
apparel
|
||||
apple
|
||||
apples
|
||||
appliance
|
||||
approval
|
||||
arch
|
||||
argument
|
||||
arithmetic
|
||||
arm
|
||||
army
|
||||
art
|
||||
attack
|
||||
attempt
|
||||
attention
|
||||
attraction
|
||||
aunt
|
||||
authority
|
||||
babies
|
||||
baby
|
||||
back
|
||||
badge
|
||||
bag
|
||||
bait
|
||||
balance
|
||||
ball
|
||||
balloon
|
||||
balls
|
||||
banana
|
||||
band
|
||||
base
|
||||
baseball
|
||||
basin
|
||||
basket
|
||||
basketball
|
||||
bat
|
||||
bath
|
||||
battle
|
||||
bead
|
||||
beam
|
||||
bean
|
||||
bear
|
||||
bears
|
||||
beast
|
||||
bed
|
||||
bedroom
|
||||
beds
|
||||
bee
|
||||
beef
|
||||
beetle
|
||||
beggar
|
||||
beginner
|
||||
behavior
|
||||
belief
|
||||
believe
|
||||
bell
|
||||
bells
|
||||
berry
|
||||
bike
|
||||
bikes
|
||||
bird
|
||||
birds
|
||||
birth
|
||||
birthday
|
||||
bit
|
||||
bite
|
||||
blade
|
||||
blood
|
||||
blow
|
||||
board
|
||||
boat
|
||||
boats
|
||||
body
|
||||
bomb
|
||||
bone
|
||||
book
|
||||
books
|
||||
boot
|
||||
border
|
||||
bottle
|
||||
boundary
|
||||
box
|
||||
boy
|
||||
boys
|
||||
brain
|
||||
brake
|
||||
branch
|
||||
brass
|
||||
bread
|
||||
breakfast
|
||||
breath
|
||||
brick
|
||||
bridge
|
||||
brother
|
||||
brothers
|
||||
brush
|
||||
bubble
|
||||
bucket
|
||||
building
|
||||
bulb
|
||||
bun
|
||||
burn
|
||||
burst
|
||||
bushes
|
||||
business
|
||||
butter
|
||||
button
|
||||
cabbage
|
||||
cable
|
||||
cactus
|
||||
cake
|
||||
cakes
|
||||
calculator
|
||||
calendar
|
||||
camera
|
||||
camp
|
||||
can
|
||||
cannon
|
||||
canvas
|
||||
cap
|
||||
caption
|
||||
car
|
||||
card
|
||||
care
|
||||
carpenter
|
||||
carriage
|
||||
cars
|
||||
cart
|
||||
cast
|
||||
cat
|
||||
cats
|
||||
cattle
|
||||
cause
|
||||
cave
|
||||
celery
|
||||
cellar
|
||||
cemetery
|
||||
cent
|
||||
chain
|
||||
chair
|
||||
chairs
|
||||
chalk
|
||||
chance
|
||||
change
|
||||
channel
|
||||
cheese
|
||||
cherries
|
||||
cherry
|
||||
chess
|
||||
chicken
|
||||
chickens
|
||||
children
|
||||
chin
|
||||
church
|
||||
circle
|
||||
clam
|
||||
class
|
||||
clock
|
||||
clocks
|
||||
cloth
|
||||
cloud
|
||||
clouds
|
||||
clover
|
||||
club
|
||||
coach
|
||||
coal
|
||||
coast
|
||||
coat
|
||||
cobweb
|
||||
coil
|
||||
collar
|
||||
color
|
||||
comb
|
||||
comfort
|
||||
committee
|
||||
company
|
||||
comparison
|
||||
competition
|
||||
condition
|
||||
connection
|
||||
control
|
||||
cook
|
||||
copper
|
||||
copy
|
||||
cord
|
||||
cork
|
||||
corn
|
||||
cough
|
||||
country
|
||||
cover
|
||||
cow
|
||||
cows
|
||||
crack
|
||||
cracker
|
||||
crate
|
||||
crayon
|
||||
cream
|
||||
creator
|
||||
creature
|
||||
credit
|
||||
crib
|
||||
crime
|
||||
crook
|
||||
crow
|
||||
crowd
|
||||
crown
|
||||
crush
|
||||
cry
|
||||
cub
|
||||
cup
|
||||
current
|
||||
curtain
|
||||
curve
|
||||
cushion
|
||||
dad
|
||||
daughter
|
||||
day
|
||||
death
|
||||
debt
|
||||
decision
|
||||
deer
|
||||
degree
|
||||
design
|
||||
desire
|
||||
desk
|
||||
destruction
|
||||
detail
|
||||
development
|
||||
digestion
|
||||
dime
|
||||
dinner
|
||||
dinosaurs
|
||||
direction
|
||||
dirt
|
||||
discovery
|
||||
discussion
|
||||
disease
|
||||
disgust
|
||||
distance
|
||||
distribution
|
||||
division
|
||||
dock
|
||||
doctor
|
||||
dog
|
||||
dogs
|
||||
doll
|
||||
dolls
|
||||
donkey
|
||||
door
|
||||
downtown
|
||||
drain
|
||||
drawer
|
||||
dress
|
||||
drink
|
||||
driving
|
||||
drop
|
||||
drug
|
||||
drum
|
||||
duck
|
||||
ducks
|
||||
dust
|
||||
ear
|
||||
earth
|
||||
earthquake
|
||||
edge
|
||||
education
|
||||
effect
|
||||
egg
|
||||
eggnog
|
||||
eggs
|
||||
elbow
|
||||
end
|
||||
engine
|
||||
error
|
||||
event
|
||||
example
|
||||
exchange
|
||||
existence
|
||||
expansion
|
||||
experience
|
||||
expert
|
||||
eye
|
||||
eyes
|
||||
face
|
||||
fact
|
||||
fairies
|
||||
fall
|
||||
family
|
||||
fan
|
||||
fang
|
||||
farm
|
||||
farmer
|
||||
father
|
||||
faucet
|
||||
fear
|
||||
feast
|
||||
feather
|
||||
feeling
|
||||
feet
|
||||
fiction
|
||||
field
|
||||
fifth
|
||||
fight
|
||||
finger
|
||||
fire
|
||||
fireman
|
||||
fish
|
||||
flag
|
||||
flame
|
||||
flavor
|
||||
flesh
|
||||
flight
|
||||
flock
|
||||
floor
|
||||
flower
|
||||
flowers
|
||||
fly
|
||||
fog
|
||||
fold
|
||||
food
|
||||
foot
|
||||
force
|
||||
fork
|
||||
form
|
||||
fowl
|
||||
frame
|
||||
friction
|
||||
friend
|
||||
friends
|
||||
frog
|
||||
frogs
|
||||
front
|
||||
fruit
|
||||
fuel
|
||||
furniture
|
||||
galley
|
||||
game
|
||||
garden
|
||||
gate
|
||||
geese
|
||||
ghost
|
||||
giants
|
||||
giraffe
|
||||
girl
|
||||
girls
|
||||
glass
|
||||
glove
|
||||
glue
|
||||
goat
|
||||
gold
|
||||
goldfish
|
||||
good-bye
|
||||
goose
|
||||
government
|
||||
governor
|
||||
grade
|
||||
grain
|
||||
grandfather
|
||||
grandmother
|
||||
grape
|
||||
grass
|
||||
grip
|
||||
ground
|
||||
group
|
||||
growth
|
||||
guide
|
||||
guitar
|
||||
gun
|
||||
hair
|
||||
haircut
|
||||
hall
|
||||
hammer
|
||||
hand
|
||||
hands
|
||||
harbor
|
||||
harmony
|
||||
hat
|
||||
hate
|
||||
head
|
||||
health
|
||||
hearing
|
||||
heart
|
||||
heat
|
||||
help
|
||||
hen
|
||||
hill
|
||||
history
|
||||
hobbies
|
||||
hole
|
||||
holiday
|
||||
home
|
||||
honey
|
||||
hook
|
||||
hope
|
||||
horn
|
||||
horse
|
||||
horses
|
||||
hose
|
||||
hospital
|
||||
hot
|
||||
hour
|
||||
house
|
||||
houses
|
||||
humor
|
||||
hydrant
|
||||
ice
|
||||
icicle
|
||||
idea
|
||||
impulse
|
||||
income
|
||||
increase
|
||||
industry
|
||||
ink
|
||||
insect
|
||||
instrument
|
||||
insurance
|
||||
interest
|
||||
invention
|
||||
iron
|
||||
island
|
||||
jail
|
||||
jam
|
||||
jar
|
||||
jeans
|
||||
jelly
|
||||
jellyfish
|
||||
jewel
|
||||
join
|
||||
joke
|
||||
journey
|
||||
judge
|
||||
juice
|
||||
jump
|
||||
kettle
|
||||
key
|
||||
kick
|
||||
kiss
|
||||
kite
|
||||
kitten
|
||||
kittens
|
||||
kitty
|
||||
knee
|
||||
knife
|
||||
knot
|
||||
knowledge
|
||||
laborer
|
||||
lace
|
||||
ladybug
|
||||
lake
|
||||
lamp
|
||||
land
|
||||
language
|
||||
laugh
|
||||
lawyer
|
||||
lead
|
||||
leaf
|
||||
learning
|
||||
leather
|
||||
leg
|
||||
legs
|
||||
letter
|
||||
letters
|
||||
lettuce
|
||||
level
|
||||
library
|
||||
lift
|
||||
light
|
||||
limit
|
||||
line
|
||||
linen
|
||||
lip
|
||||
liquid
|
||||
list
|
||||
lizards
|
||||
loaf
|
||||
lock
|
||||
locket
|
||||
look
|
||||
loss
|
||||
love
|
||||
low
|
||||
lumber
|
||||
lunch
|
||||
lunchroom
|
||||
machine
|
||||
magic
|
||||
maid
|
||||
mailbox
|
||||
man
|
||||
manager
|
||||
map
|
||||
marble
|
||||
mark
|
||||
market
|
||||
mask
|
||||
mass
|
||||
match
|
||||
meal
|
||||
measure
|
||||
meat
|
||||
meeting
|
||||
memory
|
||||
men
|
||||
metal
|
||||
mice
|
||||
middle
|
||||
milk
|
||||
mind
|
||||
mine
|
||||
minister
|
||||
mint
|
||||
minute
|
||||
mist
|
||||
mitten
|
||||
mom
|
||||
money
|
||||
monkey
|
||||
month
|
||||
moon
|
||||
morning
|
||||
mother
|
||||
motion
|
||||
mountain
|
||||
mouth
|
||||
move
|
||||
muscle
|
||||
music
|
||||
nail
|
||||
name
|
||||
nation
|
||||
neck
|
||||
need
|
||||
needle
|
||||
nerve
|
||||
nest
|
||||
net
|
||||
news
|
||||
night
|
||||
noise
|
||||
north
|
||||
nose
|
||||
note
|
||||
notebook
|
||||
number
|
||||
nut
|
||||
oatmeal
|
||||
observation
|
||||
ocean
|
||||
offer
|
||||
office
|
||||
oil
|
||||
operation
|
||||
opinion
|
||||
orange
|
||||
oranges
|
||||
order
|
||||
organization
|
||||
ornament
|
||||
oven
|
||||
owl
|
||||
owner
|
||||
page
|
||||
pail
|
||||
pain
|
||||
paint
|
||||
pan
|
||||
pancake
|
||||
paper
|
||||
parcel
|
||||
parent
|
||||
park
|
||||
part
|
||||
partner
|
||||
party
|
||||
passenger
|
||||
paste
|
||||
patch
|
||||
payment
|
||||
peace
|
||||
pear
|
||||
pen
|
||||
pencil
|
||||
person
|
||||
pest
|
||||
pet
|
||||
pets
|
||||
pickle
|
||||
picture
|
||||
pie
|
||||
pies
|
||||
pig
|
||||
pigs
|
||||
pin
|
||||
pipe
|
||||
pizzas
|
||||
place
|
||||
plane
|
||||
planes
|
||||
plant
|
||||
plantation
|
||||
plants
|
||||
plastic
|
||||
plate
|
||||
play
|
||||
playground
|
||||
pleasure
|
||||
plot
|
||||
plough
|
||||
pocket
|
||||
point
|
||||
poison
|
||||
police
|
||||
polish
|
||||
pollution
|
||||
popcorn
|
||||
porter
|
||||
position
|
||||
pot
|
||||
potato
|
||||
powder
|
||||
power
|
||||
price
|
||||
print
|
||||
prison
|
||||
process
|
||||
produce
|
||||
profit
|
||||
property
|
||||
prose
|
||||
protest
|
||||
pull
|
||||
pump
|
||||
punishment
|
||||
purpose
|
||||
push
|
||||
quarter
|
||||
quartz
|
||||
queen
|
||||
question
|
||||
quicksand
|
||||
quiet
|
||||
quill
|
||||
quilt
|
||||
quince
|
||||
quiver
|
||||
rabbit
|
||||
rabbits
|
||||
rail
|
||||
railway
|
||||
rain
|
||||
rainstorm
|
||||
rake
|
||||
range
|
||||
rat
|
||||
rate
|
||||
ray
|
||||
reaction
|
||||
reading
|
||||
reason
|
||||
receipt
|
||||
recess
|
||||
record
|
||||
regret
|
||||
relation
|
||||
religion
|
||||
representative
|
||||
request
|
||||
respect
|
||||
rest
|
||||
reward
|
||||
rhythm
|
||||
rice
|
||||
riddle
|
||||
rifle
|
||||
ring
|
||||
rings
|
||||
river
|
||||
road
|
||||
robin
|
||||
rock
|
||||
rod
|
||||
roll
|
||||
roof
|
||||
room
|
||||
root
|
||||
rose
|
||||
route
|
||||
rub
|
||||
rule
|
||||
run
|
||||
sack
|
||||
sail
|
||||
salt
|
||||
sand
|
||||
scale
|
||||
scarecrow
|
||||
scarf
|
||||
scene
|
||||
scent
|
||||
school
|
||||
science
|
||||
scissors
|
||||
screw
|
||||
sea
|
||||
seashore
|
||||
seat
|
||||
secretary
|
||||
seed
|
||||
selection
|
||||
self
|
||||
sense
|
||||
servant
|
||||
shade
|
||||
shake
|
||||
shame
|
||||
shape
|
||||
sheep
|
||||
sheet
|
||||
shelf
|
||||
ship
|
||||
shirt
|
||||
shock
|
||||
shoe
|
||||
shoes
|
||||
shop
|
||||
show
|
||||
side
|
||||
sidewalk
|
||||
sign
|
||||
silk
|
||||
silver
|
||||
sink
|
||||
sister
|
||||
sisters
|
||||
size
|
||||
skate
|
||||
skin
|
||||
skirt
|
||||
sky
|
||||
slave
|
||||
sleep
|
||||
sleet
|
||||
slip
|
||||
slope
|
||||
smash
|
||||
smell
|
||||
smile
|
||||
smoke
|
||||
snail
|
||||
snails
|
||||
snake
|
||||
snakes
|
||||
sneeze
|
||||
snow
|
||||
soap
|
||||
society
|
||||
sock
|
||||
soda
|
||||
sofa
|
||||
son
|
||||
song
|
||||
songs
|
||||
sort
|
||||
sound
|
||||
soup
|
||||
space
|
||||
spade
|
||||
spark
|
||||
spiders
|
||||
sponge
|
||||
spoon
|
||||
spot
|
||||
spring
|
||||
spy
|
||||
square
|
||||
squirrel
|
||||
stage
|
||||
stamp
|
||||
star
|
||||
start
|
||||
statement
|
||||
station
|
||||
steam
|
||||
steel
|
||||
stem
|
||||
step
|
||||
stew
|
||||
stick
|
||||
sticks
|
||||
stitch
|
||||
stocking
|
||||
stomach
|
||||
stone
|
||||
stop
|
||||
store
|
||||
story
|
||||
stove
|
||||
stranger
|
||||
straw
|
||||
stream
|
||||
street
|
||||
stretch
|
||||
string
|
||||
structure
|
||||
substance
|
||||
sugar
|
||||
suggestion
|
||||
suit
|
||||
summer
|
||||
sun
|
||||
support
|
||||
surprise
|
||||
sweater
|
||||
swim
|
||||
swing
|
||||
system
|
||||
table
|
||||
tail
|
||||
talk
|
||||
tank
|
||||
taste
|
||||
tax
|
||||
teaching
|
||||
team
|
||||
teeth
|
||||
temper
|
||||
tendency
|
||||
tent
|
||||
territory
|
||||
test
|
||||
texture
|
||||
theory
|
||||
thing
|
||||
things
|
||||
thought
|
||||
thread
|
||||
thrill
|
||||
throat
|
||||
throne
|
||||
thumb
|
||||
thunder
|
||||
ticket
|
||||
tiger
|
||||
time
|
||||
tin
|
||||
title
|
||||
toad
|
||||
toe
|
||||
toes
|
||||
tomatoes
|
||||
tongue
|
||||
tooth
|
||||
toothbrush
|
||||
toothpaste
|
||||
top
|
||||
touch
|
||||
town
|
||||
toy
|
||||
toys
|
||||
trade
|
||||
trail
|
||||
train
|
||||
trains
|
||||
tramp
|
||||
transport
|
||||
tray
|
||||
treatment
|
||||
tree
|
||||
trees
|
||||
trick
|
||||
trip
|
||||
trouble
|
||||
trousers
|
||||
truck
|
||||
trucks
|
||||
tub
|
||||
turkey
|
||||
turn
|
||||
twig
|
||||
twist
|
||||
umbrella
|
||||
uncle
|
||||
underwear
|
||||
unit
|
||||
use
|
||||
vacation
|
||||
value
|
||||
van
|
||||
vase
|
||||
vegetable
|
||||
veil
|
||||
vein
|
||||
verse
|
||||
vessel
|
||||
vest
|
||||
view
|
||||
visitor
|
||||
voice
|
||||
volcano
|
||||
volleyball
|
||||
voyage
|
||||
walk
|
||||
wall
|
||||
war
|
||||
wash
|
||||
waste
|
||||
watch
|
||||
water
|
||||
wave
|
||||
waves
|
||||
wax
|
||||
way
|
||||
wealth
|
||||
weather
|
||||
week
|
||||
weight
|
||||
wheel
|
||||
whip
|
||||
whistle
|
||||
wilderness
|
||||
wind
|
||||
window
|
||||
wine
|
||||
wing
|
||||
winter
|
||||
wire
|
||||
wish
|
||||
woman
|
||||
women
|
||||
wood
|
||||
wool
|
||||
word
|
||||
work
|
||||
worm
|
||||
wound
|
||||
wren
|
||||
wrench
|
||||
wrist
|
||||
writer
|
||||
writing
|
||||
yak
|
||||
yam
|
||||
yard
|
||||
yarn
|
||||
year
|
||||
yoke
|
||||
zebra
|
||||
zephyr
|
||||
zinc
|
||||
zipper
|
||||
zoo
|
111
src/lib.rs
111
src/lib.rs
@ -1,24 +1,24 @@
|
||||
//! This crate provides a generate that constructs random name strings suitable
|
||||
//! for use in container instances, project names, application instances, etc.
|
||||
//! This crate provides a generate that constructs suitably random and reasonably unique human
|
||||
//! readable (and fairly adorable) ids, ala GiphyCat.
|
||||
//!
|
||||
//! The name `Generator` implements the `Iterator` trait so it can be used with
|
||||
//! adapters, consumers, and in loops.
|
||||
//!
|
||||
//! # Usage
|
||||
//!
|
||||
//! This crate is [on crates.io](https://crates.io/crates/names) and can be
|
||||
//! used by adding `names` to your dependencies in your project's `Cargo.toml`
|
||||
//! This crate is [on crates.io](https://crates.io/crates/adjective_adjective_animal) and can be
|
||||
//! used by adding `adjective_adjective_animal` to your dependencies in your project's `Cargo.toml`
|
||||
//! file:
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! names = "0.9.0"
|
||||
//! adjective_adjective_animal = "0.9.0"
|
||||
//! ```
|
||||
//!
|
||||
//! and this to your crate root:
|
||||
//!
|
||||
//! ```
|
||||
//! extern crate names;
|
||||
//! extern crate adjective_adjective_animal;
|
||||
//! ```
|
||||
//!
|
||||
//! # Example: painless defaults
|
||||
@ -27,38 +27,27 @@
|
||||
//! a name:
|
||||
//!
|
||||
//! ```
|
||||
//! use names::Generator;
|
||||
//! use adjective_adjective_animal::Generator;
|
||||
//!
|
||||
//! let mut generator = Generator::default();
|
||||
//! println!("Your project is: {}", generator.next().unwrap());
|
||||
//! // #=> "Your project is: rusty-nail"
|
||||
//! ```
|
||||
//!
|
||||
//! If more randomness is required, you can generate a name with a trailing
|
||||
//! 4-digit number:
|
||||
//!
|
||||
//! ```
|
||||
//! use names::{Generator, Name};
|
||||
//!
|
||||
//! let mut generator = Generator::with_naming(Name::Numbered);
|
||||
//! println!("Your project is: {}", generator.next().unwrap());
|
||||
//! // #=> "Your project is: pushy-pencil-5602"
|
||||
//! // #=> "Your project is: IndustrialSecretiveSwan"
|
||||
//! ```
|
||||
//!
|
||||
//! # Example: with custom dictionaries
|
||||
//!
|
||||
//! If you would rather supply your own custom adjective and noun word lists,
|
||||
//! If you would rather supply your own custom adjective and animal word lists,
|
||||
//! you can provide your own by supplying 2 string slices. For example,
|
||||
//! this returns only one result:
|
||||
//!
|
||||
//! ```
|
||||
//! use names::{Generator, Name};
|
||||
//! use adjective_adjective_animal::Generator;
|
||||
//!
|
||||
//! let adjectives = &["imaginary"];
|
||||
//! let nouns = &["roll"];
|
||||
//! let mut generator = Generator::new(adjectives, nouns, Name::default());
|
||||
//! let adjectives = &["Imaginary"];
|
||||
//! let animals = &["Bear"];
|
||||
//! let mut generator = Generator::new(adjectives, animals);
|
||||
//!
|
||||
//! assert_eq!("imaginary-roll", generator.next().unwrap());
|
||||
//! assert_eq!("ImaginaryImaginaryBear", generator.next().unwrap());
|
||||
//! ```
|
||||
|
||||
extern crate rand;
|
||||
@ -68,32 +57,16 @@ use rand::Rng;
|
||||
pub const ADJECTIVES: &'static [&'static str] =
|
||||
&include!(concat!(env!("OUT_DIR"), "/adjectives.rs"));
|
||||
|
||||
pub const NOUNS: &'static [&'static str] = &include!(concat!(env!("OUT_DIR"), "/nouns.rs"));
|
||||
pub const ANIMALS: &'static [&'static str] = &include!(concat!(env!("OUT_DIR"), "/animals.rs"));
|
||||
|
||||
/// A naming strategy for the `Generator`
|
||||
pub enum Name {
|
||||
/// This represents a plain naming strategy of the form `"ADJECTIVE-NOUN"`
|
||||
Plain,
|
||||
/// This represents a naming strategy with a random number appended to the
|
||||
/// end, of the form `"ADJECTIVE-NOUN-NUMBER"`
|
||||
Numbered,
|
||||
}
|
||||
|
||||
impl Default for Name {
|
||||
fn default() -> Self {
|
||||
Name::Plain
|
||||
}
|
||||
}
|
||||
|
||||
/// A random name generator which combines an adjective, a noun, and an
|
||||
/// A random name generator which combines an adjective, a animal, and an
|
||||
/// optional number
|
||||
///
|
||||
/// A `Generator` takes a slice of adjective and noun words strings and has
|
||||
/// A `Generator` takes a slice of adjective and animal words strings and has
|
||||
/// a naming strategy (with or without a number appended).
|
||||
pub struct Generator<'a> {
|
||||
adjectives: &'a [&'a str],
|
||||
nouns: &'a [&'a str],
|
||||
naming: Name,
|
||||
animals: &'a [&'a str],
|
||||
}
|
||||
|
||||
impl<'a> Generator<'a> {
|
||||
@ -102,54 +75,34 @@ impl<'a> Generator<'a> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use names::{Generator, Name};
|
||||
/// use adjective_adjective_animal::Generator;
|
||||
///
|
||||
/// let adjectives = &["sassy"];
|
||||
/// let nouns = &["clocks"];
|
||||
/// let naming = Name::Plain;
|
||||
/// let adjectives = &["Sassy"];
|
||||
/// let animals = &["Fox"];
|
||||
///
|
||||
/// let mut generator = Generator::new(adjectives, nouns, naming);
|
||||
/// let mut generator = Generator::new(adjectives, animals);
|
||||
///
|
||||
/// assert_eq!("sassy-clocks", generator.next().unwrap());
|
||||
/// assert_eq!("SassySassyFox", generator.next().unwrap());
|
||||
/// ```
|
||||
pub fn new(adjectives: &'a [&'a str], nouns: &'a [&'a str], naming: Name) -> Self {
|
||||
pub fn new(adjectives: &'a [&'a str], animals: &'a [&'a str]) -> Self {
|
||||
Generator {
|
||||
adjectives: adjectives,
|
||||
nouns: nouns,
|
||||
naming: naming,
|
||||
animals: animals,
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct and returns a default `Generator<'a>` containing a large
|
||||
/// collection of adjectives and nouns
|
||||
///
|
||||
/// ```
|
||||
/// use names::{Generator, Name};
|
||||
///
|
||||
/// let mut generator = Generator::with_naming(Name::Plain);
|
||||
///
|
||||
/// println!("My new name is: {}", generator.next().unwrap());
|
||||
/// ```
|
||||
pub fn with_naming(naming: Name) -> Self {
|
||||
Generator::new(ADJECTIVES, NOUNS, naming)
|
||||
}
|
||||
|
||||
fn rand_adj(&self) -> &str {
|
||||
rand::thread_rng().choose(self.adjectives).unwrap()
|
||||
}
|
||||
|
||||
fn rand_noun(&self) -> &str {
|
||||
rand::thread_rng().choose(self.nouns).unwrap()
|
||||
}
|
||||
|
||||
fn rand_num(&self) -> u16 {
|
||||
rand::thread_rng().gen_range(1, 10000)
|
||||
fn rand_animal(&self) -> &str {
|
||||
rand::thread_rng().choose(self.animals).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Default for Generator<'a> {
|
||||
fn default() -> Self {
|
||||
Generator::new(ADJECTIVES, NOUNS, Name::default())
|
||||
Generator::new(ADJECTIVES, ANIMALS)
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,12 +110,6 @@ impl<'a> Iterator for Generator<'a> {
|
||||
type Item = String;
|
||||
|
||||
fn next(&mut self) -> Option<String> {
|
||||
let adj = self.rand_adj();
|
||||
let noun = self.rand_noun();
|
||||
|
||||
Some(match self.naming {
|
||||
Name::Plain => format!("{}-{}", adj, noun),
|
||||
Name::Numbered => format!("{}-{}-{:04}", adj, noun, self.rand_num()),
|
||||
})
|
||||
Some(format!("{}{}{}", self.rand_adj(), self.rand_adj(), self.rand_animal()))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user