All Projects → gulien → Orbit

gulien / Orbit

Licence: mit
📡 A cross-platform task runner for executing commands and generating files from templates

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Orbit

Oldterminal
an old terminal template for html pages
Stars: ✭ 140 (-5.41%)
Mutual labels:  template
Uicard
Generic UI for card games like Hearthstone, Magic Arena and Slay the Spire...
Stars: ✭ 142 (-4.05%)
Mutual labels:  template
Moderncppstarter
🚀 Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.
Stars: ✭ 2,381 (+1508.78%)
Mutual labels:  template
Studorlio
Portfolio website template
Stars: ✭ 141 (-4.73%)
Mutual labels:  template
Tedivms Flask
Flask starter app with celery, bootstrap, and docker environment
Stars: ✭ 142 (-4.05%)
Mutual labels:  template
Android Template
Android app starter template
Stars: ✭ 141 (-4.73%)
Mutual labels:  template
Westwind.razorhosting
Hosting the Razor Runtime outside of ASP.NET/MVC for use in non-Web .NET applications.
Stars: ✭ 136 (-8.11%)
Mutual labels:  template
Competitive Programming
VastoLorde95's solutions to 2000+ competitive programming problems from various online judges
Stars: ✭ 147 (-0.68%)
Mutual labels:  template
Touch Bar Istats
Show CPU/GPU/MEM temperature on Touch Bar with BetterTouchTool!
Stars: ✭ 141 (-4.73%)
Mutual labels:  template
Devmvp
一键生成MVP架构基础代码-Android Studio模板
Stars: ✭ 145 (-2.03%)
Mutual labels:  template
Kotlin Gradle Plugin Template
🐘 A template to let you started with custom Gradle Plugins + Kotlin in a few seconds
Stars: ✭ 141 (-4.73%)
Mutual labels:  template
Smoke
💨 Simple yet powerful file-based mock server with recording abilities
Stars: ✭ 142 (-4.05%)
Mutual labels:  template
Gulp Nunjucks
Precompile Nunjucks templates
Stars: ✭ 143 (-3.38%)
Mutual labels:  template
Jupiter
jupiter是一个aio web框架,基于aiohttp。支持(restful格式、扫描注解、依赖注入、jinja2模板引擎、ORM框架)等。
Stars: ✭ 140 (-5.41%)
Mutual labels:  template
Awesome Chrome Extension Boilerplate
Use react + typescript + webpack to enhance your chrome extension development experience
Stars: ✭ 146 (-1.35%)
Mutual labels:  template
Automatic Gatsbyjs App Landing Page
Automatic GatsbyJS App Landing Page - Automatically generate iOS app landing page using GatsbyJS
Stars: ✭ 137 (-7.43%)
Mutual labels:  template
Eros Template
🔧 eros app 开发模板。
Stars: ✭ 143 (-3.38%)
Mutual labels:  template
Nn Template
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.
Stars: ✭ 145 (-2.03%)
Mutual labels:  template
Warp Api Starter Template
A boilerplate template for starting a web services using Warp + SQLx (PostgreSQL) + Redis + Juniper (GraphQL). ❤️
Stars: ✭ 145 (-2.03%)
Mutual labels:  template
Wordmove
Multi-stage command line deploy/mirroring and task runner for Wordpress
Stars: ✭ 1,791 (+1110.14%)
Mutual labels:  task-runner

orbit's logo

Orbit

A cross-platform task runner for executing commands and generating files from templates

Travis CI AppVeyor GoDoc Go Report Card Codecov


Orbit started with the need to find a cross-platform alternative of make and sed -i commands. As it does not aim to be as powerful as these two commands, Orbit offers an elegant solution for running tasks and generating files from templates, whatever the platform you're using.

Menu

Install

Download the latest release of Orbit from the releases page. You can get Orbit for a large range of OS and architecture.

The file you downloaded is a compressed archive. You'll need to extract the Orbit binary and move it into a folder where you can execute it easily.

Linux/MacOS:

tar -xzf orbit*.tar.gz orbit
sudo mv ./orbit /usr/local/bin && chmod +x /usr/local/bin/orbit

Windows:

Right click on the file and choose Extract All.

Move the binary to a folder like C:\Orbit. Then, add it in your Path system environment variables. Click System, Advanced system settings, Environment Variables... and open Path under System variables. Edit the Variable value by adding the folder with the Orbit binary.

Alright, you're almost done 🤘! Let's check your installation by running:

orbit version

Generating a file from a template

Orbit uses the Go package text/template under the hood as a template engine. It provides a interesting amount of logic for your templates.

The Go documentation and the Hugo documentation cover a lot of features that aren't mentioned here. Don't hesitate to take a look at these links to understand the Go template engine! 😃

Also, Orbit provides Sprig library and three custom functions:

  • os which returns the current OS name at runtime (you may find all available names in the official documentation).
  • verbose which returns true if logging is set to info level.
  • debug which returns true if logging is set to debug level.

Command description

Base

orbit generate [flags]

Flags

-f --file

Specify the path of the template. This flag is required.

-o --output

Specify the output file which will be generated from the template.

Good to know: if no output is specified, Orbit will print the result to Stdout.

-p --payload

The flag -p allows you to specify many data sources which will be applied to your template:

orbit generate [...] -p "key_1,file_1.yml"
orbit generate [...] -p "key_1,file_1.yml;key_2,file_2.toml;key_3,file_3.json;key_4,.env;key_5,some raw data"

As you can see, Orbit handles 5 types of data sources:

  • YAML files (*.yaml, *.yml)
  • TOML files (*.toml)
  • JSON files (*.json)
  • .env files
  • raw data

The data will be accessible in your template through {{ .Orbit.my_key.my_data }}.

If you don't want to specify the payload each time your running orbit generate, you may also create a file named orbit-payload.yml in the folder where your running your command:

payload:

    - key: my_key
      value: my_file.yml
      
    - key: my_other_key
      value: Some raw data

By doing so, running orbit generate [...] will be equivalent to running orbit generate [...] -p "my_key,my_file.yml;my_other_key,Some raw data".

Note: you are able to override a data source from the file orbit-payload.yml if you set the same key in the -p flag.

-t --templates

The flag -t allows you to specify additional templates which are used in your template:

orbit generate [...] -t "template_1.txt"
orbit generate [...] -t "template_1.txt,template_2.yml"
orbit generate [...] -t "template_1.txt,template_2.yml,../../template_3.toml"

So, in order to generate a file from this template:

{{ template "additional_template.txt" }}

You should run:

orbit generate [...] -t "path/to/additional_template.txt"

If you don't want to specify the templates each time your running orbit generate, you may also use the file orbit-payload.yml in the folder where your running your command:

payload:

[...]

templates:

  - template_1.txt
  - template_2.yml

By doing so, running orbit generate [...] will be equivalent to running orbit generate [...] -t "template_1.txt,template_2.yml".

--delimiters

The flag --delimiters allows you to specify an alternative template delimiter pair (left/open, right/close). If unspecified, the Go defaults ({{ and }}) will be used. Note that, if this option is used, exactly two delimiters must be specified.

Examples:

orbit generate [...] --delimiters "<<,>>"
orbit generate [...] --delimiters "<<" --delimiters ">>"

The first delimiter (<< in the examples above) is used for the left/opening delimiter while the second delimiter (>> in the examples above) is used for the right/closing delimiter. This applies regardless of whether the delimiters are specified as a comma-separated pair (first example) or by repeated use of the option (second example).

-v --verbose

Sets logging to info level.

-d --debug

Sets logging to debug level.

Basic example

Let's create our simple template template.yml:

companies:

{{- range $company := .Orbit.Values.companies }}
  - name: {{ $company.name }}
    launchers:
  {{- range $launcher := $company.launchers }}
    - {{ $launcher }}
  {{ end }}
{{- end }}

And the data provided a YAML file named data-source.yml:

companies:

  - name: SpaceX
    launchers:
      - Falcon 9
      - Falcon Heavy
      
  - name: Blue Origin
    launchers:
      - New Shepard
      - New Glenn

agencies:

  - name: ESA
    launchers:
      - Ariane 5
      - Vega

The command for generating a file from this template is quite simple:

orbit generate -f template.yml -p "Values,data-source.yml" -o companies.yml

This command will create the companies.yml file with this content:

companies:

  - name: SpaceX
    launchers:
      - Falcon 9
      - Falcon Heavy
      
  - name: Blue Origin
    launchers:
      - New Shepard
      - New Glenn

Defining and running tasks

Command description

Base

orbit run [tasks] [flags]

Flags

-f --file

Like the make command with its Makefile, Orbit requires a configuration file (YAML, by default orbit.yml) where you define your tasks:

tasks:

  - use: my_first_task
    short: My first task short description
    run:
      - command [args]
      - command [args]
      - ...
      
  - use: my_second_task
    private: true
    run:
      - command [args]
      - command [args]
      - ...
  • the use attribute is the name of your task.
  • the short attribute is optional and is displayed when running orbit run.
  • the private attribute is optional and hides the considered task when running orbit run.
  • the run attribute is the stack of commands to run.
  • a command is a binary which is available in your $PATH.

Once you've created your orbit.yml file, you're able to run your tasks with:

orbit run my_first_task
orbit run my_second_task
orbit run my_first_task my_second_task

Notice that you may run nested tasks 🤘!

Also a cool feature of Orbit is its ability to read its configuration through a template.

For example, if you need to execute a platform specific script, you may write:

tasks:

  - use: script
    run:
    {{ if ne "windows" os }}
      - my_script.sh
    {{ else }}
      - .\my_script.bat
    {{ end }}

Orbit will automatically detect the shell you're using (with the SHELL environment variable on POSIX system and COMSPEC on Windows).

Running the task script from the previous example will in fact executes cmd.exe /c .\my_script.bat on Windows or /bin/sh -c my_script.sh (or /bin/zsh -c my_script.sh etc.) on others OS.

Of course, if you want to specify the binary which is calling your commands, there is a shell attribute available:

tasks:

  - use: script
    shell: /bin/bash -c
    run:
      - command [args]
      - ...

Last but not least, a task is able to call others tasks within the same context thanks to the run function:

tasks:

  - use: task
    run:
      - {{ run "subtask_1" "subtask_2" }}

  - use: subtask_1
    run:
      - command [args]
      - ...
     
  - use: subtask_2
    run:
      - command [args]
      - ...
-p --payload

The flag -p allows you to specify many data sources which will be applied to your configuration file.

It works the same as the -p flag from the generate command.

Of course, you may also create a file named orbit-payload.yml in the same folder where you're executing Orbit.

-t --templates

The flag -t allows you to specify additional templates which are used in your configuration file.

It works the same as the -t flag from the generate command.

Of course, you may also create a file named orbit-payload.yml in the same folder where you're executing Orbit.

-v --verbose

Sets logging to info level.

-d --debug

Sets logging to debug level.

Basic example

Let's create our simple configuration file orbit.yml:

tasks:

  - use: prepare
    run:
     - orbit generate -f configuration.template.yml -o configuration.yml -p "Data,config.json"
     - echo "configuration.yml has been succesfully created!"

You are now able to run the task prepare with:

orbit run prepare

This task will:

  • create a file named configuration.yml
  • print configuration.yml has been succesfully created! to Stdout

Voilà! 😃


Would you like to update this documentation ? Feel free to open an issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].