Coder Social home page Coder Social logo

command's Introduction

Tarsana

The Goal

The aim is to have an ecosystem in which developers can build and share command line apps (commands for short).

To acheive this goal, several components are needed:

  1. A framework to build commands.
  2. A command to create, install and publish commands (like composer and npm).
  3. A public repository to browse and search for commands (like packagist and npmjs.com).

The Framework

The PHP language was chosen simply because I wanted to rewrite my lumen-generators using this framework. Now I start to consider switching to Javascript...

To build a working version of the framwork, I need the following components:

  • filesystem to read, write and manipulate streams, files and directories.
  • syntax to parse structured strings (mainly used to parse command line args).
  • terminal to read from, write to, and handle interactions on the console.
  • command to build command line apps and test them easily.

In the process, I built these useful components:

  • functional because I liked functional programming and Ramda
  • Should create, copy, move and delete files and directories.
  • Should list and find files in directories.
  • Should read from and write to streams and files.
  • Should mock files and directories into memory (useful for testing).
  • Should parse and dump basic types: Boolean, Number, Array and Object.
  • Should define syntaxes using just a string.
  • Should define custom syntaxes easily.
  • Should write to console with formating and colors.
  • Should read inputs from the console: character, key, word, line.
  • Should handle interactive console.
  • Should mock interactive console (useful for testing).

A command should be able to:

  • Read from and write to console.
  • Easily define and parse command line args.
  • Show detailed help message.
  • Call another command and pass raw or parsed arguments.
  • Should be able to test any command.
  • Compose other commands (pipe, parallel, switch, ...).
  • Be lazy (writing changes to Filesystem only if everything goes well).
  • Auto complete command line args.
  • Should define useful functions (inspired from RamdaJS).
  • Should have a flexible and Lazy Stream class.
  • Should be as efficient as possible (sacrifice clean code).

The Tarsana Command

...

command's People

Contributors

delirious-lettuce avatar dependabot[bot] avatar lotharthesavior avatar lpmi-13 avatar maartenbusstra avatar webneat avatar xdamman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

command's Issues

options are not working alone.

Hi, thanks for this great package.
I am working in a project where I just need options. I do not need arguments. However, I realized that if I do not set at least 1 argument, the options are ignored.

How to Replicate:

class Executer extends Command {
    protected function init ()
    {
        $this->name('Generator')
            ->version('1.0.0')
            ->description('Tool to generate openapi')
            ->options(['--initialize'])
            ->describe('--initialize', 'Create the initial file structure.');
    }

    protected function execute(): void
    {
        var_dump($this->options);       
    }
}

OTUPUT:
./openapi-generator --initialize

array(1) {
  '--initialize' =>
  bool(false)
}

Adding Arguments (syntax):

class Executer extends Command {
    protected function init ()
    {
        $this->name('Generator')
            ->version('1.0.0')
            ->description('Tool to generate openapi')
            ->syntax('count: (number: 1)')
            ->options(['--initialize'])
            ->describe('--initialize', 'Create the initial file structure.');
    }

    protected function execute(): void
    {
        var_dump($this->options);       
    }
}



OTUPUT:
./openapi-generator --initialize

array(1) {
  '--initialize' =>
  bool(true)
}

As you can see, if I pass only options they are never found. Is there a way to use options only or should I have to pass at least one argument?

Thanks for your help.

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.