diff --git a/cli-bot/README.md b/cli-bot/README.md index 1a28d3602..776a90da4 100644 --- a/cli-bot/README.md +++ b/cli-bot/README.md @@ -5,19 +5,21 @@ Quickly find required kotlin-faker functionality from your terminal ## ToC + * [Installation](#installation) * [Usage](#usage) - * [Available commands](#available-commands) - * [list](#list) - * [lookup](#lookup) - * [Available options](#available-options) - * [--verbose](#verbose-output) - * [--java-syntax](#switch-to-java-syntax) - * [--locale](#using-non-default-locale) - * [--list-locales](#list-available-locales) + * [Available commands](#available-commands) + * [list](#list) + * [lookup](#lookup) + * [Available options](#available-options) + * [--verbose](#verbose-output) + * [--java-syntax](#switch-to-java-syntax) + * [--locale](#using-non-default-locale) + * [--list-locales](#list-available-locales) * [Thanks](#thanks) ## Installation + The native images are available on [releases](https://github.com/serpro69/kotlin-faker/releases) page. Download the image to a desired location and make it executable or use below script (Depends on [jq](https://stedolan.github.io/jq/)) @@ -28,36 +30,47 @@ chmod a+x ~/faker-bot ``` ## Usage + Usage details are also available with the `--help` option: `./faker-bot --help` `./faker-bot list --help` `./faker-bot lookup --help` ### Available commands + #### `list` + * `./faker-bot list` - list all providers and their functions * `./faker-bot list Address Name` - list functions of `Address` and `Name` providers (Case insensitive) Since version `1.4.0` partial matching is also supported: + * `./faker-bot list addr` - list functions of `Address` provider -#### `lookup` -* `./faker-bot lookup name` - lookup functions by name (Case insensitive partial matching) +#### `lookup` + +* `./faker-bot lookup name` - lookup providers and functions by name (Case insensitive partial matching) ### Available options + #### Verbose output + `./faker-bot list --verbose` - prints sample values for each function `./faker-bot lookup name --verbose` - prints sample values for each function #### Switch to java syntax + `./faker-bot list --java-syntax` - prints list of all available providers and their functions using java syntax #### Using non-default locale -`./faker-bot list --verbose --locale de` - combined with `--verbose`, all localized functions will be printed + +`./faker-bot list --verbose --locale de` - combined with `--verbose`, all localized functions will be printed using `de` locale. #### List available locales + `./faker-bot list --list-locales` - prints all available locales ## Thanks + Inspired by [faker-ruby/faker-bot](https://github.com/faker-ruby/faker-bot) diff --git a/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/subcommands/Lookup.kt b/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/subcommands/Lookup.kt index 546f0c6c0..856b41256 100644 --- a/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/subcommands/Lookup.kt +++ b/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/subcommands/Lookup.kt @@ -42,10 +42,10 @@ object Lookup : Runnable { val filteredMap = introspector.providerData .mapValuesTo(mutableMapOf()) { (_, fpPair) -> val (functions, properties) = fpPair - functions.filter { it.name.lowercase().contains(functionName.lowercase()) } to + functions.filter { it.toString().lowercase().contains(functionName.lowercase()) } to properties.filter { (sub, funcs) -> - sub.name.lowercase().contains(functionName.lowercase()) || - funcs.any { f -> f.name.lowercase().contains(functionName.lowercase()) } + sub.toString().lowercase().contains(functionName.lowercase()) || + funcs.any { f -> f.toString().lowercase().contains(functionName.lowercase()) } } }.filterValues { (funcs, subFuncs) -> funcs.count() > 0 || subFuncs.isNotEmpty()