Skip to content
forked from squioc/phony

tiny command line fake data generator

Notifications You must be signed in to change notification settings

SEKOIA-IO/phony

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phony

Tiny command line program that accepts a template and outputs fake data.

Examples

# publish email to nsq every 1ms.
echo '{"email":"{{email}}", "subject": "welcome!"}' \
  | phony --tick 1ms \
  | json-to-nsq --topic users

# add users to FoundationDB.
echo "'set {{username}} {{avatar}}'" \
  | phony \
  | xargs -L1 -n3 fdbcli --exec

# add users to MongoDB.
echo "'db.users.insert({ name: \"{{name}}\" })'" \
  | phony \
  | xargs -L1 -n1 mongo --eval

# add users to Redis.
echo "set {{username}} {{avatar}}" \
  | phony \
  | xargs -L1 -n3 redis-cli

# send a single request using curl.
echo 'country={{country}}' \
  | phony --max 1 \
  | curl -d @- httpbin.org/post

Installation

$ go get github.com/yields/phony

Usage


Usage: phony
  [--tick d]
  [--max n]
  [--list]

  phony -h | --help
  phony -v | --version

Options:
  --list          list all available generators
  --max n         generate data up to n [default: -1]
  --tick d        generate data every d [default: 10ms]
  -v, --version   show version information
  -h, --help      show help information

Generators

Avatar

Generate an uri to an avatar picture

$ echo "{{avatar}}" | phony --max 1
https://s3.amazonaws.com/uifaces/faces/twitter/areus/128.jpg

Choice

Select randomly one of the arguments

$ echo "{{choice:Viewed,Purchased,Watched,Clicked}}" | phony --max 1
Watched

Color

Generate a textual name of a color

$ echo "{{color}}" | phony --max 1
red

Country

Generate the name of a country

$ echo "{{country}}" | phony --max 1
Argentina

Country code

Generate the short alphabetic geographical code of a country

$ echo "{{country.code}}" | phony --max 1
AR

Domain

Generate a domain

$ echo "{{domain}}" | phony --max 1
example.com

Domain name

Generate a domain name

$ echo "{{domain.name}}" | phony --max 1
example

Domain TLD

Generate a domain TLD

$ echo "{{domain.name}}" | phony --max 1
org

Double

Generate a double number

$ echo "{{double}}" | phony --max 1
12.23

Email

Generate an email address

$ echo "{{email}}" | phony --max 1
[email protected]

Geohash

Generate a geohash

Arguments:

  • the precision of the geohash (optional; default to 12)
$ echo "{{geo.hash:10}}" | phony --max 1
zvtfye3v6b

Http method

Generate a HTTP method

$ echo "{{http.method}}" | phony --max 1
GET

Id

Generate an identifier

$ echo "{{id}}" | phony --max 1
az23eGE23e

Ipv4

Generate an ipv4 address

$ echo "{{ipv4}}" | phony --max 1
10.23.45.67

Ipv6

Generate an ipv6 address

$ echo "{{ipv6}}" | phony --max 1
2001:cafe:85:b:cf:62:60:81

KSUID

Generate a k-sortable unique id

$ echo "{{ksuid}}" | phony --max 1
1Zlye1QoDrANrPV9MP6c1tMU4yd

Latitude

Generate a geographical latitude

$ echo "{{geo.latitude}}" | phony --max 1
-64.007899

Longitude

Generate a geographical longitude

$ echo "{{geo.longitude}}" | phony --max 1
-176.537284

Mac address

Generate a mac address

$ echo "{{mac.address}}" | phony --max 1
cd:da:8d:e7:c5:e3

Person name

Generate a person name

$ echo "{{name}}" | phony --max 1
Britta Mccarthy

Firstname

Generate a firstname

$ echo "{{name.first}}" | phony --max 1
Filiberto

Lastname

Generate a lastname

$ echo "{{name.last}}" | phony --max 1
Walton

Product category

Generate a product category

$ echo "{{product.category}}" | phony --max 1
Clothing

Product name

Generate a product name

$ echo "{{product.name}}" | phony --max 1
Namdax

Random integer

Generate a random integer

Arguments:

  • the minimum value of the random integer (optional)
  • the maximum value of the random integer (mandatory)
$ echo "{{randint:100}}" | phony --max 1
71
$ echo "{{randint:20,50}}" | phony --max 1
34

State

Generate a USA state

$ echo "{{state}}" | phony --max 1
Idaho

State code

Generate the short code of a USA state

$ echo "{{state.code}}" | phony --max 1
AZ

Timezone

Generate a timezone

$ echo "{{timezone}}" | phony --max 1
America/Phoenix

Unixtime

Generate an Unix time

$ echo "{{unixtime}}" | phony --max 1
1585421720493623000

Username

Generate a username

$ echo "{{username}}" | phony --max 1
kerem

UUID

Generate an uuid

$ echo "{{uuid}}" | phony --max 1
f8b3a519-2e83-427f-b3a6-53e617310690

License

(MIT), 2014 Amir Abu Shareb.

About

tiny command line fake data generator

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Makefile 0.1%