Coder Social home page Coder Social logo

vai's Introduction

vai ⚡️

A CLI script runtime to bring order to your scripts (or not)

Overview

vai is a little piece of bash scripting that aims at enforcing a certain organization in how scripts advertise their use as well as providing a way of discovering a other commands that belong to a given project.

This can be best understood with an example.

Say that our project has 3 scripts that perform the following functions:

  • say-hello.sh: prints hello to stdout
  • say-world: adds one to whatever comes in the first arg
  • say-haha: reverses a string

We can take the traditional method of simply putting all of them under a directory and creating a README.md that documents it. Or, use vai and implement few methods that advertise their functionality:

scripts
├── say-haha.sh
├── say-hello.sh
└── say-world.sh

Each of these scripts would then implement two methods: description and main.

Having these two methods implemented, the expected interface is fulfilled and so vai can route executions to them.

#!/bin/bash

description () {
  echo 'Prints `hello` to stdout.'
}

main () {
  echo "hello!"
}

eval "$@"

This way, vai list shows the commands:

vai

  USAGE:
    vai <command> [args]

  COMMANDS:
    help                  Prints a command's help message                   
    say-world             Prints `world` to stdout.                         
    say-hello             Prints `hello` to stdout.                         
    description           Prints a project's description                    
    list                  Lists available 'vai' commands                    
    say-haha              Prints `haha` to stdout.                          

vai say-world
world!

Should I use this?

Well, maybe yes, maybe not.

This was meant to be just a quick experiment and is probably not suitable for real use case. However, feel free to make use of it if you find useful 👌

vai's People

Stargazers

Renan Ivo avatar

Watchers

James Cloos avatar  avatar

vai's Issues

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.