Skip to content

methodology for creating top level actions à la Dockêr #36

Description

@ORESoftware

With docker in mind, we have a command line API like so:

docker run
docker build
docker ps

or with Istanbul in mind:

istanbul cover
istanbul report
istanbul instrument

or git:

git merge
git rebase
git checkout

etc.

is there a methodology for creating this kind of top-level action api with dashdash?

AFAICT, you'd have to make a homegrown system from dashdash, and from what I can tell, you'd have to enforce that the first argument after docker was the action.

Right now, I have a CLI API using dashdash, but it's more akin to:

docker --run
docker --cp
docker --ps
docker --create
docker --images

where the actions are all just booleans according my dashdash config.

Just something to discuss.

I think it would be a neat feature if dashdash could take an initialization argument to interpret the first x _args as actions. And these would be stored as a separate property on opts.

So it would be something like this:

const dashdash = require('dashdash');

let opts, parser = dashdash.createParser({options: options}, {
   actions: 1  // => the first arg is interpreted as an action, and it has to appear before any options 
});

try {
  opts = parser.parse(process.argv);
} catch (err) {
 // 
}

// opts => {};
// opts._args => []
// opts._actions => [] 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions