Giter Site home page Giter Site logo

cli's Introduction

#Cli Php automatic cli. Bash suggest and help pages just by creating classes

  • Automatic suggest list of commands. Show php doc as help.
Using way
  • just start type any command and press tab to get bash suggests
     acli [tab]

Also component checks requires parameters for your users, shows help

Creating command
  • Create class extended from CliUnit at commands directory.
  • All command method should ends on ..Action
  • Use string parameters to get any values
Requirements
  • PHP 7+
installation
  • composer.json:
    {
        "repositories": [
            {
                "url": "https://github.com/AKikhaev/Cli.git",
                "type": "vcs"
            }
        ],
        "require": {
            "akikhaev/cli": "~1.0"
        }
    }
  • composer install
  • add bash suggester registration to .bash_aliases or just run register.sh for test purpose
#mcedit ~/.bash_aliases

function acli() {
    local PWD=$(pwd -P)
    if  [[ -f "$PWD/acli" ]] ; then
        php acli "$@"
    fi
}

function _acli_complete_()
{
    local PWD=$(pwd -P)
    if  [[ -f "$PWD/acli" ]] ; then
        #local pwds
        #IFS='/' read -r -a pwds <<< "$PWD"
        ##mapfile -d / -t pwds <<<"$PWD/"
        #projectName=${pwds[3]}

        local cmd="${1##*/}"
        local cur_word="${COMP_WORDS[COMP_CWORD]}"
        local prev_word="${COMP_WORDS[COMP_CWORD-1]}"
        local line_full=${COMP_LINE}
        local line=$(printf " %s" "${COMP_WORDS[@]:1}"); line=${line:1}
        local suggestAcli=$(php acli $line --silence_greetings --bash_completion_cword=$cur_word --cword_num=$COMP_CWORD)
        COMPREPLY=($(compgen -W "$suggestAcli" -- $cur_word))
    else
        COMPREPLY=()
    fi
}

complete -F _acli_complete_ acli

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.