• Stars
    star
    786
  • Rank 57,890 (Top 2 %)
  • Language
    Go
  • Created over 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple Go / YAML-based task runner for the team.

Robo

Build Status

Simple YAML-based task runner written in Go.

Features

  • Not super slow
  • Not super obscure
  • No dependencies
  • Variables
  • Simple

Installation

From gobinaries.com:

$ curl -sf https://gobinaries.com/tj/robo | sh

From source:

$ go get github.com/tj/robo

Usage

Command-line usage.

Listing tasks

Output tasks:

$ robo

  aws – amazon web services cli
  circle.open – open the repo in circle ci
  events – send data to the "events" topic
  push – push image from the current directory

Task help

Output task help:

$ robo help events

  Usage:

    events [project-id] [rate]

  Description:

    send data to the "events" topic

  Examples:

    Send 25 events a second to gy2d
    $ robo events gy2d 25

Running tasks

Regardless of task type (shell, exec, script) any additional arguments given will be passed.

For example suppose you have the following task:

aws:
  exec: ssh tools aws

You may then interact with the AWS cli as you would normally:

$ robo aws help
$ robo aws ec2 describe-instances

Configuration

Task configuration.

Commands

The most basic task simply runs a shell command:

hello:
  summary: some task
  command: echo world

You may also define multi-line commands with YAML's |:

hello:
  summary: some task
  command: |
    echo hello
    echo world

Commands are executed via sh -c, thus you may use shell features and positional variables, for example:

hello:
  command: echo "Hello ${1:-there}"

Yields:

$ robo hello
Hello there

$ robo hello Tobi
Hello there Tobi

Exec

The exec alternative lets you replace the robo image without the fork & shell, however note that shell features are not available (pipes, redirection, etc).

hello:
  summary: some task
  exec: echo hello

Any arguments given are simply appended.

Scripts

Shell scripts may be used instead of inline commands:

hello:
  summary: some task
  script: path/to/script.sh

If the script is executable, it is invoked directly, this allows you to use #!:

$ echo -e '#!/usr/bin/env ruby\nputs "yo"' > yo.rb
$ chmod +x yo.rb
$ cat > robo.yml
yo:
  summary: yo from rb
  script: yo.rb
^C
$ robo yo
yo

Script paths are relative to the config file, not the working directory.

Usage

Tasks may optionally specify usage parameters, which display upon help output:

events:
  summary: send data to the "events" topic
  exec: docker run -it events
  usage: "[project-id] [rate]"

Examples

Tasks may optionally specify any number of example commands, which display upon help output:

events:
  summary: send data to the "events" topic
  exec: docker run -it events
  usage: "[project-id] [rate]"
  examples:
    - description: Send 25 events a second to gy2d
      command: robo events gy2d 25

Variables

Robo supports variables via the text/template package. All you have to do is define a map of variables and use {{ }} to refer to them.

Here's an example:

stage:
  summary: Run commands against stage.
  exec: ssh {{.hosts.stage}} -t robo

prod:
  summary: Run commands against prod.
  exec: ssh {{.hosts.prod}} -t robo

variables:
  hosts:
    prod: bastion-prod
    stage: bastion-stage

The variables section does also interpolate itself with its own data via {{ .var }} and allows shell like command expressions via $(echo true) to be executed first providing the output result as a variable. Note that variables are interpolated first and then command expressions are evaluated. This will allow you to reduce repetitive variable definitions and declarations.

hash:
  summary: echos the git {{ .branch }} branch's git hash
  command: echo {{ .branch }} {{ .githash }}

variables:
  branch: master
  githash: $(git rev-parse --short {{ .branch }})

Along with your own custom variables, robo defines the following variables:

$ robo variables

    robo.file: /Users/amir/dev/src/github.com/tj/robo/robo.yml
    robo.path: /Users/amir/dev/src/github.com/tj/robo

    user.home: /Users/amir
    user.name: Amir Abushareb
    user.username: amir

Environment

Tasks may define env key with an array of environment variables, this allows you to re-use robo configuration files, for example:

// aws.yml
dev:
  summary: AWS commands in dev environment
  exec: aws
  env: ["AWS_PROFILE=eng-dev"]

stage:
  summary: AWS commands in stage environment
  exec: aws
  env: ["AWS_PROFILE=eng-stage"]

prod:
  summary: AWS commands in prod environment
  exec: aws
  env: ["AWS_PROFILE=eng-prod"]

You can also override environment variables:

$ cat > robo.yml
home:
  summary: overrides $HOME
  exec: echo $HOME
  env: ["HOME=/tmp"]
^C
$ robo home // => /tmp

Variables can also be used to set env vars.

$ cat > robo.yml
aws-stage:
  summary: AWS stage
  exec: aws
  env: ["AWS_PROFILE={{.aws.profile}}"]
variables:
  aws:
    profile: eng-stage
^C
$ robo aws-stage ...

Note that you cannot use shell featurs in the environment key.

Setup / Cleanup

Some tasks or even your entire robo configuration may require steps upfront for setup or afterwards for a cleanup. The keywords before and after can be embedded into a task or into the overall robo configuration. It has the same executable syntax as a task: script, exec and command. Defining it on a task level causes the steps to be executed before (respectively after) the task. Global before or after steps are invoked for every task in the configuration. All steps get interpolated the same way tasks and variables are interpolated.

before:
  - command: echo "global before {{ .foo }}"
after:
  - script: /global/after-script.sh

foo:
  before:
    - command: echo "local before {{ .foo }}"
    - exec: git pull -r
  after:
    - command: echo "local after"
    - exec: git reset --hard HEAD
  exec: git status

variables:
  foo: bar

Templates

Task list and help output may be re-configured, for example if you prefer to view usage information instead of the summary:

templates:
  list: |
    {{range .Tasks}}  {{cyan .Name}} – {{.Usage}}
    {{end}}

Or perhaps something more verbose:

templates:
  list: |
    {{range .Tasks}}
      name: {{cyan .Name}}
      summary: {{.Summary}}
      usage: {{.Usage}}
    {{end}}

Global tasks

By default ./robo.yml is loaded, however if you want global tasks you can simply alias to something like:

alias segment='robo --config ~/.robo.yml'

Robo chaining

You can easily use Robo to chain Robo, which is useful for multi-environment setups. For example:

prod:
  summary: production tasks
  exec: robo --config production.yml

stage:
  summary: stage tasks
  exec: robo --config stage.yml

Or on remote boxes:

prod:
  summary: production tasks
  exec: ssh prod-tools -t robo --config production.yml

stage:
  summary: stage tasks
  exec: ssh stage-tools -t robo --config stage.yml

You can also use robo's builtin variables robo.path, for example if you put all robofiles in together:

β”œβ”€β”€ dev.yml
β”œβ”€β”€ prod.yml
β”œβ”€β”€ root.yml
└── stage.yml

And you would like to call dev, prod and stage from root:

dev:
  summary: Development commands
  exec: robo --config {{ .robo.path }}/dev.yml

stage:
  ...

Composition

You can compose multiple commands into a single command by utilizing robo's built-in robo.file variable:

one:
  summary: echo one
  command: echo one

two:
  summary: echo two
  command: echo two

all:
  summary: echo one two
  command: |
    robo -c {{ .robo.file }} one
    robo -c {{ .robo.file }} two
$ robo all
one
two

Why?

We generally use Makefiles for project specific tasks, however the discoverability of global tasks within a large team is difficult unless there's good support for self-documentation, which Make is bad at.

I'm aware of the million other solutions (Sake, Thor, etc) but I just wanted something fast without dependencies.

License

MIT

More Repositories

1

commander.js

node.js command-line interfaces made easy
JavaScript
26,707
star
2

n

Node version management
Shell
18,855
star
3

git-extras

GIT utilities -- repo summary, repl, changelog population, author commit percentages and more
Shell
17,295
star
4

co

The ultimate generator based flow-control goodness for nodejs (supports thunks, promises, etc)
JavaScript
11,853
star
5

ejs

Embedded JavaScript templates for node
JavaScript
4,450
star
6

node-prune

Remove unnecessary files from node_modules (.md, .ts, ...)
Go
4,297
star
7

consolidate.js

Template engine consolidation library for node.js
JavaScript
3,476
star
8

frontend-boilerplate

webpack-react-redux-babel-autoprefixer-hmr-postcss-css-modules-rucksack-boilerplate (unmaintained, I don't use it anymore)
JavaScript
2,939
star
9

connect-redis

Redis session store for Connect
TypeScript
2,788
star
10

should.js

BDD style assertions for node.js -- test framework agnostic
JavaScript
2,757
star
11

luna

luna programming language - a small, elegant VM implemented in C
C
2,446
star
12

dox

JavaScript documentation generator for node using markdown and jsdoc
JavaScript
2,159
star
13

mmake

Modern Make
Go
1,717
star
14

terminal-table

Ruby ASCII Table Generator, simple and feature rich.
Ruby
1,522
star
15

node-migrate

Abstract migration framework for node
JavaScript
1,522
star
16

axon

message-oriented socket library for node.js heavily inspired by zeromq
JavaScript
1,495
star
17

react-enroute

React router with a small footprint for modern browsers
JavaScript
1,490
star
18

commander

The complete solution for Ruby command-line executables
Ruby
1,089
star
19

mon

mon(1) - Simple single-process process monitoring program written in C
C
1,065
star
20

reds

light-weight, insanely simple full text search module for node.js - backed by Redis
JavaScript
891
star
21

node-thunkify

Turn a regular node function into one which returns a thunk
JavaScript
858
star
22

react-click-outside

ClickOutside component for React.
JavaScript
775
star
23

gobinaries

Golang binaries compiled on-demand for your system
Go
770
star
24

node-blocked

Check if the event loop is blocked
JavaScript
722
star
25

node-ratelimiter

Abstract rate limiter for nodejs
JavaScript
719
star
26

staticgen

Static website generator that lets you use HTTP servers and frameworks you already know
Go
712
star
27

histo

beautiful charts in the terminal for static or streaming data
C
697
star
28

serve

Simple command-line file / directory server built with connect - supports stylus, jade, etc
JavaScript
563
star
29

styl

Flexible and fast modular CSS preprocessor built on top of Rework
JavaScript
525
star
30

pomo

Ruby Pomodoro app for the command-line (time / task management)
Ruby
525
star
31

go-spin

Terminal spinner package for Golang
Go
521
star
32

mdconf

Markdown driven configuration!
JavaScript
507
star
33

node-growl

growl unobtrusive notification system for nodejs
JavaScript
484
star
34

watch

watch(1) periodically executes the given command - useful for auto-testing, auto-building, auto-anything
C
458
star
35

node-querystring

querystring parser for node and the browser - supporting nesting (used by Express, Connect, etc)
JavaScript
452
star
36

node-delegates

Nodejs method and accessor delegation utility
JavaScript
418
star
37

haml.js

Faster Haml JavaScript implementation for nodejs
JavaScript
409
star
38

triage

Interactive command-line GitHub issue & notification triaging tool.
Go
399
star
39

log.js

super light-weight nodejs logging + streaming log reader
HTML
368
star
40

go-tea

Tea provides an Elm inspired functional framework for interactive command-line programs.
Go
364
star
41

punt

Elegant UDP messaging for nodejs
JavaScript
341
star
42

react-fatigue-dev

Module of modules for making modules
Makefile
312
star
43

php-selector

PHP DOM parser / queries with CSS selectors
PHP
300
star
44

node-gify

Convert videos to gifs using ffmpeg and gifsicle
JavaScript
296
star
45

palette

Node.js image color palette extraction with node-canvas
JavaScript
292
star
46

better-assert

c-style assert() for nodejs, reporting the expression string as the error message
JavaScript
285
star
47

js-yaml

CommonJS YAML Parser -- fast, elegant and tiny yaml parser for javascript
JavaScript
275
star
48

go-naturaldate

Natural date/time parsing for Go.
Go
272
star
49

lingo

Linguistics module for Node - inflection, transformation, i18n and more
JavaScript
270
star
50

react-batch

Batch component for performant frequent updates (flush on count or interval)
JavaScript
251
star
51

sponsors-api

GitHub Sponsor avatar listings in your Readme.md
Go
244
star
52

mad

mad(1) is a markdown manual page viewer
Shell
244
star
53

d3-heatmap

D3 heatmap
JavaScript
243
star
54

go-update

Go package for auto-updating system-specific binaries via GitHub releases.
Go
241
star
55

callsite

node.js access to v8's "raw" CallSites -- useful for custom traces, c-style assertions, getting the line number in execution etc
JavaScript
239
star
56

bm

CLI bookmarks -- dropbox persisted bookmarks in your terminal - view screenshots in your browser
Shell
229
star
57

term-canvas

javascript canvas api for your terminal!
JavaScript
226
star
58

go-termd

Package termd provides terminal markdown rendering, with code block syntax highlighting support.
Go
224
star
59

parse-curl.js

Parse curl commands, returning an object representing the request.
JavaScript
217
star
60

go-progress

Another Go progress bar
Go
216
star
61

es

Go DSL for Elasticsearch queries
Go
206
star
62

co-prompt

sane terminal user-input for node.js using thunks / generators
JavaScript
192
star
63

node-cookie-signature

cookie signing
JavaScript
183
star
64

co-views

Higher-level template rendering for node.js using generators
JavaScript
175
star
65

d3-bar

D3 bar chart
JavaScript
173
star
66

node-only

return whitelisted properties of an object
JavaScript
170
star
67

ngen

nodejs project generator
JavaScript
168
star
68

react-hooks

Fire off actions in stateless components.
JavaScript
167
star
69

letterbox

Go program to batch-process letter-boxing of photographs.
Go
164
star
70

go-search

Search Godoc.org via the command-line.
Go
159
star
71

co-monk

MongoDB generator goodness for node.js
JavaScript
155
star
72

eson

Extended (pluggable) JSON for node - great for configuration files and JSON transformations
JavaScript
150
star
73

growl

Ruby growlnotify 'bindings' (unobtrusive notification system)
Ruby
146
star
74

go

Go packages
Go
140
star
75

d3-series

D3 line series chart used for error reporting on Apex Ping
JavaScript
139
star
76

node-amp

Abstract message protocol for nodejs
JavaScript
135
star
77

channel.js

Go-style channel implementation for JavaScript
JavaScript
135
star
78

burl

better curl(1) through augmentation
Shell
134
star
79

node-pwd

Hash and compare passwords with pbkdf2
JavaScript
132
star
80

jog

JSON document logging & filtering inspired by loggly for node.js
JavaScript
132
star
81

nedis

Redis server implementation written with nodejs
JavaScript
131
star
82

d3-circle

D3 circle chart
JavaScript
130
star
83

d3-dot

D3 dot chart
JavaScript
129
star
84

node-term-list

Interactive terminal list for nodejs
JavaScript
126
star
85

node-comment-macros

JavaScript comment macros useful for injecting logging, tracing, debugging, or stats related code.
JavaScript
126
star
86

d3-line

D3 line chart
JavaScript
125
star
87

asset

little asset manager for lazy people (think bundler/homebrew/npm for assets). written with node
JavaScript
122
star
88

go-dropbox

Dropbox v2 client for Go.
Go
120
star
89

node-term-css

style terminal output using CSS
JavaScript
116
star
90

go-terminput

Package terminput provides terminal keyboard input for interactive command-line tools.
Go
114
star
91

vscode-snippets

Personal VSCode snippets for Go, JS, Elm, etc.
114
star
92

nshell

scriptable command-line shell written with node.js
JavaScript
109
star
93

node-actorify

Turn any node.js duplex stream into an actor
JavaScript
108
star
94

co-parallel

Execute thunks in parallel with concurrency support
JavaScript
108
star
95

node-monquery

mongodb query language for humans
JavaScript
106
star
96

co-fs

nodejs core fs module thunk wrappers for "co"
JavaScript
105
star
97

axon-rpc

Axon RPC client / server
JavaScript
103
star
98

s3.js

S3 uploads from the browser.
JavaScript
100
star
99

spa

Tiny Single Page Application server for Go with `spa` command-line tool.
Go
94
star
100

d3-tipy

D3 tooltip
JavaScript
94
star