petname

package
v0.0.0-...-5edc738 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2016 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

README

#petname

##NAME

petname − a utility to generate "pet names", consisting of a random combination of adverbs, an adjective, and an animal name

##SYNOPSIS

petname [-w|--words INT] [-l|--letters INT] [-s|--separator STR] [-d|--dir STR] [-c|--complexity INT] [-u|--ubuntu]

##OPTIONS

  • -w|--words number of words in the name, default is 2
  • -l|--letters maximum number of letters in each word, default is unlimited
  • -s|--separator string used to separate name words, default is ’-’
  • -d|--dir directory containing adverbs.txt, adjectives.txt, names.txt, default is /usr/share/petname/
  • -c|--complexity [0, 1, 2]; 0 = easy words, 1 = standard words, 2 = complex words, default=1
  • -u|--ubuntu generate ubuntu-style names, alliteration of first character of each word

##DESCRIPTION

This utility will generate "pet names", consisting of a random combination of an adverb, adjective, and an animal name. These are useful for unique hostnames or container names, for instance.

As such, PetName tries to follow the tenets of Zooko’s triangle. Names are:

  • human meaningful
  • decentralized
  • secure

##EXAMPLES

$ petname
wiggly-yellowtail

$ petname --words 1
robin

$ petname --words 3
primly-lasting-toucan

$ petname --words 4
angrily-impatiently-sage-longhorn

$ petname --separator ":"
cool:gobbler

$ petname --separator "" --words 3
comparablyheartylionfish

$ petname --ubuntu
amazed-asp

$ petname --complexity 0
massive-colt

##CODE

Besides this shell utility, there are also native libraries: python-petname, python3-petname, and golang-petname. Here are some programmatic examples in code:

Golang Example

package main

import (
	"flag"
	"fmt"
	"github.com/dustinkirkland/golang-petname"
)

var (
	words = flag.Int("words", 2, "The number of words in the pet name")
	separator = flag.String("separator", "-", "The separator between words in the pet name")
)

func main() {
	flag.Parse()
	fmt.Println(petname.Generate(\*words, \*separator))
}

Python Example See: https://pypi.golang.org/pypi/petname

$ pip install petname $ sudo apt-get install golang-petname

#!/usr/bin/python
import argparse
import petname

parser = argparse.ArgumentParser(description="Generate human readable random names")
parser.add_argument("-w", "--words", help="Number of words in name, default=2", default=2)
parser.add_argument("-s", "--separator", help="Separator between words, default='-'", default="-")
parser.options = parser.parse_args()

print petname.Generate(int(parser.options.words), parser.options.separator)

##AUTHOR

This manpage and the utility were written by Dustin Kirkland <dustin.kirkland@gmail.com> for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document and the utility under the terms of the Apache2 License.

The complete text of the Apache2 License can be found in /usr/share/common-licenses/Apache-2.0 on Debian/Ubuntu systems.


Documentation

Overview

Package petname is a library for generating human-readable, random names for objects (e.g. hostnames, containers, blobs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adjective

func Adjective() string

Adjective returns a random adjective from a list of petname adjectives.

func Adverb

func Adverb() string

Adverb returns a random adverb from a list of petname adverbs.

func Generate

func Generate(words int, separator string) string

Generate generates and returns a random pet name. It takes two parameters: the number of words in the name, and a separator token. If a single word is requested, simply a Name() is returned. If two words are requested, a Adjective() and a Name() are returned. If three or more words are requested, a variable number of Adverb() and a Adjective and a Name() is returned. The separator can be any charater, string, or the empty string.

func Name

func Name() string

Name returns a random name from a list of petname names.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL