Skip to content

solfegejs/cli

5.3.x
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@solfege/cli

Command Line Interface of SolfegeJS

Installation

The bundle is included by default in SolfegeJS. You don't need to install it.

See SolfegeJS

Available commands

In order to expore commands, you need to create a console.js file:

const solfege = require("solfegejs");

// Initialize the application
let application = solfege.factory();

// Start the application
// The first 2 parameters are removed (node and the script)
application.start(process.argv.slice(2));

Expose a command

To expose a command, you have to create a service with a specific tag:

services:
    my_command:
        class: "Command/MyCommand"
        tags:
            - { name: "solfege.console.command" }

And your class must implement 2 methods (getName and execute):

module.exports = class MyCommand {
  getName() {
    return "my-command";
  }

  async execute(parameters, options) {
    console.log("My command executed");
  }
}

Now you can call your command like that:

node console.js my-command

Tests

You need to install peer dependencies first:

npm install --no-save @solfege/application

Then run the following command:

npm test

About

Command Line Interface for SolfegeJS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published