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

commands

Stradivario edited this page Jul 16, 2018 · 2 revisions

Custom commands interface

With gapi-cli you can create custom method alias mapping which can speed up your development process.

Inside gapi-cli.conf.yml you need to add field "commands" then add your custom command like so:

commands:
   your-cli:
     my-command: 'npm -v'

This command can be executed as "gapi your-cli my-command" will print "5.7.1" in my case.

You can create Advanced command line interfaces with GAPI like in this example

Important

You can chain functions and they will be executed from top to bottom of YML file example:

  workers:
    start:
      - gapi workers start-1
      - gapi workers start-2
      - gapi workers start-3
      - gapi workers start-4
    stop:
      - docker rm -f gapi-api-prod-worker-1
      - docker rm -f gapi-api-prod-worker-2
      - docker rm -f gapi-api-prod-worker-3
      - docker rm -f gapi-api-prod-worker-4
    start-1: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.21 --name gapi-api-prod-worker-1 gapi/api/prod
    start-2: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.22 --name gapi-api-prod-worker-2 gapi/api/prod
    start-3: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.23 --name gapi-api-prod-worker-3 gapi/api/prod
    start-4: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.24 --name gapi-api-prod-worker-4 gapi/api/prod
    example-worker-with-port: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.25 --name gapi-api-prod-worker-5 -p 9001:9000 gapi/api/prod

When you add custom command for example: "workers start" and you create such a chaining with "-"

  workers:
    start:
      - gapi workers start-1
      - gapi workers start-2
      - gapi workers start-3
      - gapi workers start-4

All commands will be executed one after another from top to bottom.

Clone this wiki locally