GCLI

Easier scripting with Groovy

Лицензия

Лицензия

Категории

Категории

CLI Взаимодействие с пользователем
Группа

Группа

fr.marcwrobel
Идентификатор

Идентификатор

gcli
Последняя версия

Последняя версия

0.0.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

GCLI
Easier scripting with Groovy
Ссылка на сайт

Ссылка на сайт

https://github.com/marcwrobel/gcli
Организация-разработчик

Организация-разработчик

Marc Wrobel
Система контроля версий

Система контроля версий

https://github.com/marcwrobel/gcli

Скачать gcli

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/fr.marcwrobel/gcli/ -->
<dependency>
    <groupId>fr.marcwrobel</groupId>
    <artifactId>gcli</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/fr.marcwrobel/gcli/
implementation 'fr.marcwrobel:gcli:0.0.5'
// https://jarcasting.com/artifacts/fr.marcwrobel/gcli/
implementation ("fr.marcwrobel:gcli:0.0.5")
'fr.marcwrobel:gcli:jar:0.0.5'
<dependency org="fr.marcwrobel" name="gcli" rev="0.0.5">
  <artifact name="gcli" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.marcwrobel', module='gcli', version='0.0.5')
)
libraryDependencies += "fr.marcwrobel" % "gcli" % "0.0.5"
[fr.marcwrobel/gcli "0.0.5"]

Зависимости

provided (3)

Идентификатор библиотеки Тип Версия
org.codehaus.groovy : groovy-cli-commons jar 2.5.14
org.codehaus.groovy : groovy-sql jar 2.5.14
ch.qos.logback : logback-classic jar 1.2.3

Модули Проекта

Данный проект не имеет модулей.

Build Sonarcloud Status SonarCloud Coverage SonarCloud Vulnerabilities SonarCloud Bugs Maven Central

GCLI aims to make scripting with Groovy easier by providing opinionated utilities related to common concerns like logging or database accesses.

Requirements

Any script that uses gcli must use Java 8 or later and Groovy 2.5 or later.

Use it !

Here is a sample script that makes use of logging and database access capabilities :

#!/usr/bin/env groovy

import fr.marcwrobel.gcli.ScriptCliTexts
import groovy.sql.Sql
import groovy.util.logging.Slf4j

@Grab(group = 'fr.marcwrobel', module = 'gcli', version = '0.0.5')
@Grab(group = 'ch.qos.logback', module = 'logback-classic', version = '1.2.3')

@GrabConfig(systemClassLoader = true)
@Grab(group = 'org.postgresql', module = 'postgresql', version = '42.2.20')

final class CommandConfiguration extends DatabaseConfiguration {
  CommandConfiguration(Class<?> scriptClass) {
    super(new ScriptCliTexts(scriptClass))
  }
}

@Slf4j
class Command {

  private final CommandConfiguration config

  Command(CommandConfiguration config) {
    this.config = config
  }

  int execute() {
    try {
      config.withSql { Sql sql ->
        // do something
        return 0
      }

    } catch (Exception e) {
      log.error('Command failed : {}', e.message, e)
      throw e
    }

    log.info('Command succeeded.')
    return 0
  }
}

CommandConfiguration config = new CommandConfiguration(this.class)
if (!config.parse(args)) {
  System.exit(1)
} else if (config.showHelp) {
  config.usage()
  System.exit(0)
}

System.exit(new Command(config).execute())

Releases

Take a look at the changelog on GitHub.

Need help ?

Read the javadoc.

Raise an issue.

Email me at marc.wrobel@gmail.com.

Версии библиотеки

Версия
0.0.5