Giter Club home page Giter Club logo

shortcommand's Introduction

shortcommand

Easily run a set of commands quickly using a yaml configuration file

Usage

Create a yaml file named shortcommand.yml or anything you want. Here's an example:

shortcommands:
  - name: Journals
    commands:
      - name: ui
        description: Pull, build and deploy Web-UI
        cwd: ~/Apps/Journals/Web-UI
        do:
          - git pull
          - npm run build
      - name: api
        description: Pull, build and deploy API
        cwd: ~/Apps/Journals/API
        do:
          - git pull
          - shards build --release
          - pm2 restart "Journals API"
          - pm2 reset "Journals API"
  - name: QuickNote
    commands:
      - name: api
        description: Pull, build and deploy API
        cwd: ~/Apps/quick-note/API
        do:
          - git pull
          - pm2 restart "Quick Note API"
          - pm2 reset "Quick Note API"
      - name: restart-api
        description: Restart API in pm2
        do:
          - pm2 restart "Quick Note API"
          - pm2 reset "Quick Note API"

Then add this in your ~/.bashrc or ~/.zshrc:

export SHORTCOMMAND_CONFIG=/path/to/shortcommand.yml

Now if you run shortcommand without any arguments, you'll see this:

Available commands
Journals
  ui    Pull, build and deploy Web-UI
  api   Pull, build and deploy API
QuickNote
  api   Pull, build and deploy API
  restart-api   Restart API in pm2

Works as a readme for your command sets in case you forget what options are available for you to use.

Now the above defined short commands will be accessible and can be used by running:

shortcommand Journals ui
shortcommand Journals api
shortcommand QuickNote api
shortcommand QuickNote restart-api

Note: Commands mentioned under do: will execute in sequence and will not continue to the next one if the one that's running fails.

This project was created mainly because I have several apps that I run on my server and finding the right set of commands for deploying an app is a hassle. So this basically documents the set of commands for each of my projects, as well as gives me quick access to them.

Installing on Linux (tested on Ubuntu)

wget https://github.com/flawiddsouza/shortcommand/releases/download/v0.0.3/shortcommand_0.0.3_Linux_x86_64.tar.gz
tar -xf shortcommand_0.0.3_Linux_x86_64.tar.gz
mv shortcommand ~/.local/bin
rm shortcommand_0.0.3_Linux_x86_64.tar.gz

You should then be able to use the shortcommand command anywhere you are.

Testing

SHORTCOMMAND_CONFIG=shortcommands-example.yml go run . Test test
SHORTCOMMAND_CONFIG=shortcommands-example.yml go run . Test test2
SHORTCOMMAND_CONFIG=shortcommands-example.yml go run . Test test3

Build Testing

goreleaser build --snapshot --rm-dist

Build for release

go tag vX.X.X
git push origin vX.X.X
goreleaser release --rm-dist

shortcommand's People

Contributors

flawiddsouza avatar

Stargazers

Gábor Nagymajtényi avatar Roman avatar Sankalp Khare avatar Max avatar geogboe avatar adam kaminski avatar HappiePlant avatar Youssef avatar Jonny Griffin avatar Jason Morganson avatar  avatar Chad Moon avatar  avatar Viet Phan avatar Nikolay Kolev avatar wolfi3 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

productinfo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.