GithubHelp home page GithubHelp logo

isabella232 / oclif-base-index-command Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adobe/oclif-base-index-command

0.0 0.0 0.0 55 KB

Base oclif command for routing index.js (to support subcommands with no colons)

License: Apache License 2.0

JavaScript 99.60% Batchfile 0.40%

oclif-base-index-command's Introduction

DEPRECATED ⚠️ - This library is no longer maintained.

oclif Version Downloads/week Build Status Build status License Greenkeeper badge

oclif-base-index-command

Base oclif command for routing index.js (to support subcommands with no colons).

The Problem

For example, if you have a command foo with topics (sub-commands) bar and baz:

src
├── commands
│   └── foo
│       ├── index.js
│       ├── bar.js
│       ├── baz.js

The topics bar and baz are called this way:

my-cli foo:bar
my-cli foo:baz

However, what if you want to call them this way?

my-cli foo bar
my-cli foo baz

oclif does not support this out of the box.

This way of structuring sub-commands is important to support legacy CLIs so that they may be ported to oclif, and reduce friction for adoption.

The Solution

First, add this package to your CLI repo:

npm install @adobe/oclif-base-index-command

In your index.js (see tree structure above), add BaseIndexCommand as your class' superclass:

const BaseIndexCommand = require('@adobe/oclif-base-index-command')

class IndexCommand extends BaseIndexCommand {
  // don't override run(), let the superclass handle it
  // for the "no-colon" routing functionality
}

IndexCommand.description = `Your command's description here`


module.exports = IndexCommand

Now these commands will work without the colon topic separator:

my-cli foo bar
my-cli foo baz

oclif-base-index-command's People

Contributors

purplecabbage avatar shazron avatar

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.