Use UNIC instead of unichars

This commit is contained in:
Arne Keller 2019-05-30 12:40:33 +02:00
parent 4f27902a61
commit 7c43a8b4ca
6 changed files with 411 additions and 194 deletions

302
Cargo.lock generated
View File

@ -1,3 +1,26 @@
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "autocfg"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.0.4" version = "1.0.4"
@ -5,12 +28,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.32.0" version = "2.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -27,72 +54,231 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "fuchsia-zircon" name = "fuchsia-cprng"
version = "0.3.3" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.1.0" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.43" version = "0.2.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "numtoa"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "pwgenr" name = "pwgenr"
version = "0.3.0" version = "0.4.0"
dependencies = [ dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"unichars 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unic-ucd-block 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unic-ucd-name 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.5.5" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_chacha"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.2.1" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rand_hc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_isaac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_jitter"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_os"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_pcg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_xorshift"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_syscall"
version = "0.1.54"
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.54 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "termion"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
"numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.10.0" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "unichars" name = "unic-char-property"
version = "0.0.2" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unic-char-range 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unic-char-range"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unic-common"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unic-ucd-block"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unic-char-property 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unic-char-range 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unic-ucd-version 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unic-ucd-hangul"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unic-ucd-version 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unic-ucd-name"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unic-char-property 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unic-ucd-hangul 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unic-ucd-version 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unic-ucd-version"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unic-common 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
@ -100,13 +286,13 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "version_check" name = "vec_map"
version = "0.1.4" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.5" version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -124,20 +310,42 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata] [metadata]
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f6d018fb95a0b59f854aed68ecd96ce2b80af7911b92b1fed3c4b1fa516b91b" "checksum find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f6d018fb95a0b59f854aed68ecd96ce2b80af7911b92b1fed3c4b1fa516b91b"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880"
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
"checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
"checksum unichars 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0eccb6815251914e96be582034145d89326e73d394d91330b693c3f1edfbd2" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum unic-char-property 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"
"checksum unic-char-range 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc"
"checksum unic-common 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc"
"checksum unic-ucd-block 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b2a16f2d7ecd25325a1053ca5a66e7fa1b68911a65c5e97f8d2e1b236b6f1d7"
"checksum unic-ucd-hangul 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb1dc690e19010e1523edb9713224cba5ef55b54894fe33424439ec9a40c0054"
"checksum unic-ucd-name 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c8fc55a45b2531089dc1773bf60c1f104b38e434b774ffc37b9c29a9b0f492e"
"checksum unic-ucd-version 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -11,13 +11,15 @@ license = "GPL-3.0"
name = "pwgenr" name = "pwgenr"
readme = "README.md" readme = "README.md"
repository = "https://gitlab.com/Sakuhl/pwgenr/" repository = "https://gitlab.com/Sakuhl/pwgenr/"
version = "0.3.0" version = "0.4.0"
edition = "2018"
[dependencies] [dependencies]
clap = { version = "2.32", default-features = false } clap = "2.33.0"
lazy_static = "1.1" lazy_static = "1.3.0"
rand = "0.5.5" rand = "0.6.5"
unichars = "^0.0" unic-ucd-block = "0.9.0"
unic-ucd-name = "0.9.0"
[dev-dependencies] [dev-dependencies]
find_folder = "0.3" find_folder = "0.3"

1
rustfmt.toml Normal file
View File

@ -0,0 +1 @@
hard_tabs = true

View File

@ -1,25 +1,83 @@
use clap::{ App, Arg }; use clap::{App, Arg};
use unic_ucd_block::BlockIter;
extern crate unichars; use unic_ucd_name::Name;
use unichars::*;
use std::collections::HashMap; use std::collections::HashMap;
lazy_static! { lazy_static! {
pub static ref CATEGORIES: HashMap<&'static str, &'static [char]> = { pub static ref CATEGORIES: HashMap<&'static str, Vec<char>> = {
let mut map = HashMap::new(); let mut map: HashMap<&'static str, _> = HashMap::new();
map.insert("ascii", ASCII); map.insert(
map.insert("arrows", ARROWS); "ascii",
map.insert("box", BOX); vec![
map.insert("dingbat", DINGBAT); '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0',
map.insert("games", GAMES); '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@',
map.insert("math", MATH); 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
map.insert("symbols", SYMBOLS); 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`',
map.insert("tech", TECH); 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
],
);
map.insert(
"arrows",
get_blocks(&[
"Arrows",
"Supplemental Arrows-A",
"Supplemental Arrows-B",
"Supplemental Arrows-C",
]),
);
map.insert(
"box",
get_blocks(&[
"Box Drawing",
"Block Elements",
"Geometric Shapes",
"Geometric Shapes Extended",
]),
);
map.insert("dingbat", get_blocks(&["Dingbats"]));
map.insert(
"games",
get_blocks(&["Mahjong Tiles", "Domino Tiles", "Playing Cards"]),
);
map.insert(
"math",
get_blocks(&[
"Mathematical Operators",
"Supplemental Mathematical Operators",
"Miscellaneous Mathematical Symbols-A",
"Miscellaneous Mathematical Symbols-B",
]),
);
map.insert(
"symbols",
get_blocks(&[
"Currency Symbols",
"General Punctuation",
"Letterlike Symbols",
"Number Forms",
"Miscellaneous Symbols",
]),
);
map.insert("tech", get_blocks(&["Miscellaneous Technical"]));
map map
}; };
} }
fn get_blocks(names: &[&'static str]) -> Vec<char> {
let mut all = Vec::new();
for &n in names {
debug_assert!(BlockIter::new().any(|b| b.name == n));
}
for block in BlockIter::new().filter(|b| names.contains(&b.name)) {
for c in block.range.into_iter().filter(|&c| Name::of(c).is_some()) {
all.push(c);
}
}
all
}
fn is_int(s: String) -> Result<(), String> { fn is_int(s: String) -> Result<(), String> {
s.parse::<usize>().map(|_| ()).map_err(|e| e.to_string()) s.parse::<usize>().map(|_| ()).map_err(|e| e.to_string())
} }
@ -28,24 +86,32 @@ pub fn build_cli() -> App<'static, 'static> {
App::new("pwgenr") App::new("pwgenr")
.version(env!("CARGO_PKG_VERSION")) .version(env!("CARGO_PKG_VERSION"))
.author("Arne Keller <arne.keller01@yahoo.de>") .author("Arne Keller <arne.keller01@yahoo.de>")
.arg(Arg::with_name("categories") .arg(
Arg::with_name("categories")
.short("c") .short("c")
.takes_value(true) .takes_value(true)
.multiple(true) .multiple(true)
.possible_values(&CATEGORIES.keys().cloned().collect::<Vec<_>>()) .possible_values(&CATEGORIES.keys().cloned().collect::<Vec<_>>())
.help("Categories to be used")) .help("Categories to be used"),
.arg(Arg::with_name("clipboard") )
.arg(
Arg::with_name("clipboard")
.short("b") .short("b")
.long("clipboard") .long("clipboard")
.help("Copy first password to clipboard (requires xclip)")) .help("Copy first password to clipboard (requires xclip)"),
.arg(Arg::with_name("LENGTH") )
.arg(
Arg::with_name("LENGTH")
.takes_value(true) .takes_value(true)
.validator(is_int) .validator(is_int)
.default_value("64") .default_value("64")
.help("of the generated passwords")) .help("of the generated passwords"),
.arg(Arg::with_name("AMOUNT") )
.arg(
Arg::with_name("AMOUNT")
.takes_value(true) .takes_value(true)
.validator(is_int) .validator(is_int)
.default_value("12") .default_value("12")
.help("of generated passwords")) .help("of generated passwords"),
)
} }

View File

@ -1,20 +1,17 @@
#[macro_use] extern crate lazy_static; #[macro_use]
extern crate clap; extern crate lazy_static;
use rand::rngs::OsRng;
use rand::seq::SliceRandom;
extern crate unichars; use std::process::{exit, Command, Stdio};
use unichars::*;
extern crate rand;
use rand::{ OsRng, Rng };
use std::process::{Command, exit, Stdio};
mod cli; mod cli;
use cli::CATEGORIES;
fn gen_pw(alphabet: &[char], length: usize, rng: &mut OsRng) -> String { fn gen_pw(alphabet: &[char], length: usize, rng: &mut OsRng) -> String {
let mut buf = String::new(); let mut buf = String::new();
for _ in 0..length { for _ in 0..length {
let c = rng.choose(alphabet).unwrap(); let c = alphabet.choose(rng).unwrap();
buf.push(*c); buf.push(*c);
} }
buf buf
@ -23,8 +20,16 @@ fn gen_pw(alphabet: &[char], length: usize, rng: &mut OsRng) -> String {
fn main() { fn main() {
let matches = cli::build_cli().get_matches(); let matches = cli::build_cli().get_matches();
let length = matches.value_of("LENGTH").unwrap().parse::<usize>().unwrap(); let length = matches
let amount = matches.value_of("AMOUNT").unwrap().parse::<usize>().unwrap(); .value_of("LENGTH")
.unwrap()
.parse::<usize>()
.unwrap();
let amount = matches
.value_of("AMOUNT")
.unwrap()
.parse::<usize>()
.unwrap();
let alphabet = if let Some(categories) = matches.values_of("categories") { let alphabet = if let Some(categories) = matches.values_of("categories") {
let mut all = Vec::new(); let mut all = Vec::new();
@ -34,19 +39,16 @@ fn main() {
all all
} else { } else {
let mut all = Vec::new(); let mut all = Vec::new();
all.extend(ARROWS); for c in CATEGORIES.values() {
all.extend(ASCII); all.extend(c);
all.extend(BOX); }
all.extend(DINGBAT);
all.extend(ENCLOSED);
all.extend(GAMES);
all.extend(MATH);
all.extend(SYMBOLS);
all.extend(TECH);
all all
}; };
let mut rng = OsRng::new().unwrap_or_else(|_| { eprintln!("error: could not create CSPRNG"); exit(71) }); let mut rng = OsRng::new().unwrap_or_else(|_| {
eprintln!("error: could not create CSPRNG");
exit(71)
});
for i in 0..amount { for i in 0..amount {
let pw = gen_pw(&alphabet, length, &mut rng); let pw = gen_pw(&alphabet, length, &mut rng);
@ -59,25 +61,34 @@ fn main() {
} }
} }
fn to_clip(value: &str) { fn to_clip(value: &str) {
use std::io::*; use std::io::*;
Command::new("xclip") Command::new("xclip")
.arg("-selection") .arg("-selection")
.arg("clipboard") .arg("clipboard")
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.spawn().map_err(|e| { .spawn()
eprintln!("error: could not run xclip ({:?})", e); exit(1) .map_err(|e| {
}).map(|child| { eprintln!("error: could not run xclip ({:?})", e);
child.stdin.or_else(|| { exit(1)
eprintln!("error: could not open stdin of xclip"); exit(1) })
}).map(|mut outstdin| { .map(|child| {
child
.stdin
.or_else(|| {
eprintln!("error: could not open stdin of xclip");
exit(1)
})
.map(|mut outstdin| {
let mut writer = BufWriter::new(&mut outstdin); let mut writer = BufWriter::new(&mut outstdin);
writer.write_all(value.as_bytes()).unwrap_or_else(|e| { writer.write_all(value.as_bytes()).unwrap_or_else(|e| {
eprintln!("error: could not write to stdin of xclip ({:?})", e); exit(1) eprintln!("error: could not write to stdin of xclip ({:?})", e);
exit(1)
}); });
}) })
}).unwrap_or_else(|e| { })
eprintln!("error: {:?}", e); exit(1) .unwrap_or_else(|e| {
eprintln!("error: {:?}", e);
exit(1)
}); });
} }

View File

@ -1,71 +0,0 @@
#[macro_use] extern crate lazy_static;
extern crate find_folder;
use find_folder::Search;
extern crate unichars;
use unichars::*;
lazy_static! {
static ref PATH: ::std::path::PathBuf = { Search::ParentsThenKids(3, 3).for_folder("target").unwrap().join(::std::path::Path::new("debug/pwgenr")) };
}
macro_rules! exe {
($($arg:expr),*) => {
match ::std::process::Command::new(&*PATH)
// Start a repetition:
$(
// Each repeat will contain the following statement, with
// $arg replaced with the corresponding expression.
.arg($arg)
)*
.output()
.expect("failed to execute process") {
::std::process::Output { status: _, stdout: out, stderr: err } => {
let out = String::from_utf8(out).unwrap();
let err = String::from_utf8(err).unwrap();
println!("out\n{}\nerr\n{}", out, err);
// skip last empty line
(out.rsplit('\n').skip(1).map(|x| x.to_string()).collect::<Vec<_>>(), err)
}
}
}
}
#[test]
fn length_amount() {
let (out, _) = exe!("19", "15");
assert_eq!(out.len(), 15);
for line in &out {
assert_eq!(line.chars().count(), 19);
}
}
#[test]
fn ascii() {
let (out, _) = exe!("-c", "ascii", "--", "1", "10");
assert_eq!(out.len(), 10);
for line in &out {
assert_eq!(line.chars().count(), 1);
for c in line.chars() {
assert!(ASCII.contains(&c));
}
}
}
#[test]
fn categories() {
let (out, _) = exe!("-c", "box", "arrows", "--", "16", "20");
assert_eq!(out.len(), 20);
for line in &out {
assert_eq!(line.chars().count(), 16);
for c in line.chars() {
assert!(BOX.contains(&c) || ARROWS.contains(&c));
}
}
}
#[test]
fn empty() {
let (out, _) = exe!("0", "0");
assert_eq!(out.len(), 0);
}