Moniker.Cli 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global Moniker.Cli --version 2.0.0                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local Moniker.Cli --version 2.0.0                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Moniker.Cli&version=2.0.0                
nuke :add-package Moniker.Cli --version 2.0.0                

Moniker Build Status Moniker NuGet Moniker.CLI NuGet

<img src="https://raw.githubusercontent.com/alexmg/Moniker/develop/icon.png" align="left" style="padding-right: 15px" alt="Moniker Logo" width="68"/>

Moniker is a tiny .NET library and CLI tool for generating fun names.

It started as a port of the moniker Go package that is used by the Helm project to generate release names, but was extended to also include the name generator used by the Moby project for naming Docker containers. Both name generators use a scheme that combines a random value from a list of adjectives with another random value from a list of nouns.

In the case of Moniker the nouns are animals:

wobbly-whippet
hardy-lynx
rafting-deer
lame-gecko

For Moby they are notable scientists and hackers:

relaxed-booth
stoic-franklin
thirsty-williamson
objective-gould

.NET Standard Library

To use the .NET Standard 2.0 library install the package from NuGet.

Install-Package Moniker

Add a using statement for the Moniker namespace.

using Moniker;

The static NameGenerator class contains methods for generating new monikers:

  • GenerateMoniker - generates a Moniker style name
  • GenerateMoby - generates a Moby style name
  • Generate - generates a name using the provided MonikerStyle enum value

All methods accept an optional parameter for the delimiter to be used between the adjective and noun values that are concatenated in these naming schemes. This is a string parameter so the separator can contain multiple characters if required and a space is allowed. The default separator is the - character (e.g. pensive-jennings and wishful-shrimp).

// Moniker examples
MonikerGenerator.GenerateMoniker(); // killjoy-worm
MonikerGenerator.GenerateMoniker("_"); // killjoy_worm
MonikerGenerator.Generate(MonikerStyle.Moniker); // killjoy-worm
MonikerGenerator.Generate(MonikerStyle.Moniker, "_"); // killjoy_worm

// Moby examples
MonikerGenerator.GenerateMoby(); // priceless-volhard
MonikerGenerator.GenerateMoby("_"); // priceless_volhard
MonikerGenerator.Generate(MonikerStyle.Moby); // priceless-volhard
MonikerGenerator.Generate(MonikerStyle.Moby, "_"); // priceless_volhard

.NET Core Global Tool

To install the .NET Core Global Tool run the following dotnet command.

dotnet tool install -g Moniker.Cli

Once installed the tool can be accessed using the moniker command. Run moniker -h to see the usage instructions.

Usage: moniker [options]

Options:
  --version                   Show version information
  -s|--style <STYLE>          The style of moniker to generate (Moniker or Moby)
  -d|--delimiter <DELIMITER>  The delimiter to use between name parts such as adjective and noun
  -?|-h|--help                Show help information

The STYLE option is not mandatory and can be specified in the short form -s or long form --style. The provided value should be either Moniker or Moby depending on the desired name generator style. If omitted the moniker style defaults to Moniker.

The DELIMITER option is not mandatory and can be specified in the short form -d or long form --delimiter. If omitted the default - delimiter will be used.

In the example below a Moby style name is generated with the non-default _ delimiter.

moniker -s Moby -d _

The long form can also be used for improved readabilty.

moniker --style Moby --delimiter _

Capturing the generated name in a variable from the Windows command prompt requires some rather obscure syntax (use %%i from inside a batch file). Please let me know if you are aware of a better way.

for /f %i in ('moniker') do set NAME=%i
echo %NAME%

Capturing the output in a PowerShell variable is a simple assignment statement.

$name = moniker
Write-Host $name

A note about uniqueness

It should be noted that the lists are not particularly long and the total number of possible combinations is somewhat small (94,138 for Moniker and 25,380 for Moby). If you require names to be unique you will need to append an additional element such as a timestamp or detect duplicates yourself and request another name.

$moniker = "$(moniker)-$(Get-Date -Format 'yyMMdd')" # virulent-leopard-191022

You could also generate names using both moniker styles to extend the total range of possible names. This will provide longer but still fun sounding names.

$moniker = "$(moniker -s moby)-owns-$(moniker -s moniker)" # vibrant-newton-owns-warped-rabbit

Credits

Icon made by Roundicons from www.flaticon.com

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
2.1.0 109 9/12/2024
2.0.0 126 8/21/2024
1.0.0 2,132 11/5/2019