Giter VIP home page Giter VIP logo

phony's Introduction

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.

phony's People

Contributors

yields avatar squioc avatar bulkan avatar harlow avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.