Git Product home page Git Product logo

goose's Introduction

Goose, the dumb file generator

goose

Goose, the dumb file generator. Goose takes a file structure and replaces names with values. The values can be converted into several formats, snakecase, camelcase, dromedarcase, dasherized, spaceseparated and titlecase.

The file structure is created exactly as the template file structure with the keys replaced with the values. It is a tool similar to Thor and Yeoman, but dumber, because dumber is simpler.

Installation

goose is a single binary. Install it by right-clicking and Save as... or with curl.

Links

Curl

# OS X
$ curl -L https://github.com/andersjanmyr/goose/releases/download/v1.3.3/goose-osx \
  > /usr/local/bin/goose

# Linux
$ curl -L https://github.com/andersjanmyr/goose/releases/download/v1.3.3/goose-linux \
  > /usr/local/bin/goose

# Make executable
$ chmod a+x /usr/local/bin/goose

# Bash Completion
$ curl -L https://raw.githubusercontent.com/andersjanmyr/goose/master/goose_completion.sh \
  > /your/bash_completion/dir/

Goose Templates

A collection of Goose templates can be found in a separate repository, goose-templates. Fork it and clone it or download the latest version as a zip archive.

It is recommended to install the templates into ~/.goose

$ git clone [email protected]:andersjanmyr/goose-templates.git ~/.goose

Usage

$ goose --verbose --data "account=1234" go dingo
OPTIONS:
verbose: true
template: go
name: dingo
templateDir: /Users/andersjanmyr/.goose
outputDir: .
data: {map[NAME:dingo ACCOUNT:1234]}
Creating dir .
Generating file ./dingo.go
Generating file ./dingo_test.go
$ goose
Usage: main [options] <template> <name>
  -data=map[]: Extra data, format: key1=val1,key2=val2 (keys are upcased)
  -force=false: Force create files if they exist
  -help=false: Show help text
  -interactive=false: Ask before creating anything
  -outputdir=".": Output directory
  -templatedir="/Users/andersjanmyr/.goose": Directory where templates are stored
  -verbose=false: Be verbose

Available functions in templates are (filename suffixes in parenthesis):
	camelcase (.cc)         - MyBeautifulTapir
	dasherized (.da)        - my-beautiful-tapir
	dromedarcase (.dc)      - myBeautifulTapir
	snakecase (.sc)         - my_beautiful_tapir
	spaceseparated (.ss)    - my beautiful tapir
	titlecase (.tc)         - My Beautiful Tapir
	lowercaseletters (.ll)  - mybeautifultapir

Template Name

If <template> is a git cloneable URL it is cloned and used as the template, effectively ignoring the -templatedir parameter.

Template Files

The template files are normal go template files and support one property .NAME and functions snakecase (my_app), dasherized (my-app), camelcase (MyApp), dromedarcase (myApp), spaceseparated (my app), title case (My App), lowercaseletters (myapp).

// NAME.dc.go
package {{dromedarcase .NAME}}

func {{camelcase .NAME}}() string {
        return "{{dromedarcase .NAME}}"
}

The same functions that are available inside the templates can also be used in the filenames (and directory names), in this case they are called NAME.sc.go, NAME.da.go, NAME.cc.go, NAME.dc.go, NAME.ss.go, and NAME.tc.go.

# Example, simple structure
$ tree ~/.goose/go
go
├── NAME.dc.go
└── NAME.dc_test.go
# Example, generated simple structure
$ goose go tapir
$ tree .
.
├── tapir.go
└── tapir_test.go

# Example, bigger structure
$ tree ~/.goose/lambda/
lambda/
└── NAME.da
    ├── add-event-source.sh
    ├── create-roles.sh
    ├── generate-events.js
    ├── iam
    │   ├── lambda-assumerole-policy.json
    │   └── s3-assumerole-policy.json
    ├── invoke-lambda.sh
    ├── NAME.da.js
    ├── package.json
    └── upload-lambda.sh
# Example, generated bigger structure
$ goose lambda cool-micro-service
$ tree cool-micro-service
cool-micro-service/
├── add-event-source.sh
├── cool-micro-service.js
├── create-roles.sh
├── generate-events.js
├── iam
│   ├── lambda-assumerole-policy.json
│   └── s3-assumerole-policy.json
├── invoke-lambda.sh
├── package.json
└── upload-lambda.sh

List of Functions

  • camelcase (cc) - MyBeautifulTapir
  • dasherized (da) - my-beautiful-tapir
  • dromedarcase (dc) - myBeautifulTapir
  • snakecase (sc) - my_beautiful_tapir
  • spaceseparated (ss) - my beautiful tapir
  • titlecase (tc) - My Beautiful Tapir
  • lowercaseletters (ll) - mybeautifultapir

Release Notes

A list of changes are in the RELEASE_NOTES.

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.