Giter Club home page Giter Club logo

thaum's Introduction

Thaum ๐Ÿ”ฎ

Thaum is a boilerplate and scaffolding command line utility. It purposely requires little to no configuration and does not require you to have anything more than a mustache template to make a boilerplate. (Read: No script.)

screencapture

Features

  • No configuration.
  • Global templates and git included project templates.
  • Compiles mustache in paths for files like {{name}}.spec.js.

Install

If you have go, you can run:

$ go get github.com/flaque/thaum

or, you can run this long (but effective!) command:

$ wget "https://github.com/Flaque/thaum/releases/download/v0.6.0-beta/thaum" -O "/usr/local/bin/thaum" && sudo chmod +x /usr/local/bin/thaum

to install the binary into your path.

Note: It is much easier to run that long and scary command than to install go. Seriously, if you don't have go, just copy paste that bad boy into your terminal.

Usage

Your templates go in a folder called thaum_files. Thaum will look up the file tree for the nearest thaum_files folder and use that one for your command.

Creating a Template

Create your thaum_files in your root project.

$ mkdir thaum_files

Then create your first template! This is just a folder in your thaum_files.

$ mkdir thaum_files/myTemplate

Then, we can create a file or a whole folder system if you want inside.

$ touch thaum_files/myTemplate/myWidget.js

In that file, you can put something like this:

import {{package}};

export class {{name}} {
  constructor(foo, bar) {
    //do something
  }
}

Running Thaum

Once you have a template, you can run thaum like so:

$ thaum myTemplate

and thaum will ask you to fill in the details:

๐Ÿ”  Using thaum_files at: "/Users/Flaque/thaum-test/thaum_files"

     package: foo
        name: bang

โœ๏ธ  Created file: myWidget.js

You can also list all templates that exist by typing thaum.

$ thaum
Templates Available:
  component
  growler
  test

If you need help, you can type thaum -h to see the help screen.

$ thaum -h

Other helpful things.

If you would not like your templates to named .somethingOrAnother so that test runners or other tools don't pick them up, you can use the extension .thaum at the end of your template and thaum will remove it for you when the file is created.

For example, if I have a template file with the name:

foo_test.go.thaum

and I run thaum foo, thaum will create the file:

foo_test.go

thaum's People

Contributors

flaque avatar praxis330 avatar

Stargazers

Ricky Wu avatar Josh avatar Guillaume Gelin avatar barkpixels avatar Elise Kain avatar  avatar  avatar Andrejs Agejevs avatar  avatar  avatar  avatar Charle Demers avatar Craig Mulligan avatar  avatar Darwin Corn avatar Brian Hetro avatar Eric Clemmons avatar Jamie Wilson avatar Ramon avatar Avery avatar Ethan Mahintorabi avatar Gustavo Aguiar avatar August Murphy-Beach avatar

Watchers

James Cloos avatar Ethan Mahintorabi avatar Ricky Wu avatar  avatar  avatar

thaum's Issues

List templates available

Thaum should be able to list template names instead of requiring the user to simply look in their thaum_files folder.

I'm not sure what the command should be for this, thoughts?

Include more than just "name" variables

But it would be nice to have the ability to have more than just the name variable in the template.

So:

import "{{package}}"

class {{name}} {
  //things 
  foo({{myVariable}});
}

This could be done by checking the template for {{variables}}'s and then displaying them to the user to fill in in an output.

So the "thaum" UX could be updated to show:

$ thaum myTemplate
๐Ÿ”  Using thaum_files at: "/Users/Flaque/myProject/thaum_files"

    name       : <User has entered content here> 
    package    : <User is prompted to enter content here> 
    myVariable : <User will be prompted for this after they complete the previous> 

Pros

  • Requires 0 config files or complicated scripting (which is thaum's main reason for existing)
  • Subtly reminds the user which template by listing the variables.
  • Easy to use without needing to read docs.

Cons

  • Makes thaum a little more difficult to be used in conjunction with other scripts.
    • I'm personally okay with this as I don't see thaum as a tool that would be used like that. There are many other tools for generation in scripts out there and that's not really thaum's purpose.

Make all path generations atomic

Currently if thaum finds an error in the middle of creating a bunch of files, it will stop. This means that you can get half-completed templates, which is probably not good.

This can be fixed by having the compile function in the template create a struct of paths to be created and then create them all at the end.

Create an "Undo" feature

If users enter in the wrong template or they use the command in the wrong place, it may be nice to have an "undo" command by typing:

$ thaum -u

This could be implemented by writing to a temporary file. (afero) has a function for this. In that file, you could store a checksum and the path of each file that you created.

Then, when the user calls thaum -u, you check to see if there is a temporary file and you match the checksums of each file against the ones stored. That way we don't remove files that people have edited.

Uppercase and lowercase naming

We could include in the template a {{titleCase name}} and {{lowerCase name}} which would be the uppercase'd and lowercase'd version of the name.

For example:

"evan" -> {{lowerCase name}} -> "evan"
"Evan" -> {{lowerCase name}} -> "evan"
"Evan" -> {{titleCase name}} -> "Evan"
"evan" -> {{titleCase name}} -> "Evan" 

We should use the same format as plop does so users who feel like they need more functionality can switch over to Plop easily. We shouldn't trap anyone into using thaum.

Convert tests to testify

I can't see a whole lot of a reason to use goblin for testing. It adds a lot of boilerplate code. Which probably shouldn't exist in a project that's whole purpose is to remove boilerplate code.

These can be removed by testing with testify.

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.