Skip to main content

CLI

A CLI (Command-Line Interface) tool is vital in any project because it offers efficient, scriptable, and automation-friendly access to an application's functionality. It simplifies tasks for developers, enhancing productivity, ease of use, and scalability while providing a standardized interface for interacting with the project.

Framework X provides a CLI tool that can be used to build components to fasten you work flow. It is based on the Commander package.

Usage

The CLI tool can be used by running the following command in the terminal:

node x <command> [options]

Commands

The following commands are available:

  • build:command - Build a new command
  • build:controller - Build a new controller
  • build:middleware - Build a new middleware
  • build:repository - Build a new repository
  • build:validator - Build a new validator, based on express-validator
  • publish:stubs - Publish the stubs to the stubs folder. This is useful when you want to customize the stubs for the CLI tool.

Help

To get help on the CLI tool, run the following command:

node x --help

Examples

Build a new controller

node x build:controller user

The above command will create a new controller file controllers/user.controller.js with the following content:

const { successResponse } = require("../helpers/methods")

/**
*
* @param req
* @param res
* @returns {Promise<void>}
*/
exports.index = async (req, res) => {
res.send(
successResponse("controller index", {
data: "here comes you payload..."
})
)
}

Build a new repository

node x build:repository user

The above command will create an empty repository file repositories/user.repository.js.

Support Framework X

  • You can also support the project by following the organization and Star ⭐ the project on GitHub
  • Contribute by submitting issues and pull requests
  • Share the project with your friends and colleagues, any and all support is appreciated. 🙏
  • If you find this Framework useful, We will always appreciate a strong cup of coffee.