Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

grooviter/carbon

Repository files navigation

license Travis Bintray

What is Carbon ?

Carbon is a set of utilities to make it easier to develop http://www.groovy-lang.org scripts.

IMPORTANT: Carbon is still at alpha state.

How to use it ?

#!/usr/bin/env groovy

@Grab('com.github.grooviter:carbon:0.1.6')
import carbon.Cli

name: "hello-world"
version: "1.0.0"
description:
"""This script says @|yellow hello |@ to the name
passed as parameter:

hello-word --name John
"""

params: [
    user: [
        type: String,
        mandatory: true,
        description: 'Your name'
    ]
]

script:
Cli.withConfig()
    .logger()
    .logln("Hello ${params.user}")

If you make the script executable and execute ./hellow-world.groovy -h:

NAME:
hello-world (1.0.0)

SYNOPSIS:
hello-world [-h] -u=PARAM

DESCRIPTION:
This script says hello  to the name
passed as parameter:

hello-word --name John


OPTIONS:
  -h, --help         Shows help
  -u, --user=PARAM   Your name

AUTHORS:
Still no description

And if you execute ./hellow-world.groovy --user John:

Hello John

Installation

In order to use Carbon in your Groovy code you can find it in Bintray or Maven Central:

repositories {
    jcenter() // or mavenCentral()
}

Then you can add the dependency to your project:

compile com.github.grooviter:carbon:0.1.6'