Skip to main content
rotini

a framework for building node.js cli programs

Write your CLI as config not as code.

Features

Declarative Program Definitions

Define your program commands, arguments, and flags. Rotini will build your program and parse it; you only need to write code for your command operation handlers.

Command, Argument, and Flag Parsing

Rotini has a powerful and configurable parser. User input is checked against the program definition you provide, and command operations are handed all parsed commands, arguments, and flags.

Subcommand Support

Nest commands under commands under commands under commands... Every command you define can have its own subcommands, bringing a declarative approach to program definitions.

Command Aliases

In the event that you need to deprecate a command or want to move to a better suited command name, you can supply an alias for the command that the parser will match to your command during parsing. Each command can have multiple aliases to reduce breaking changes and to help with naming migrations.

Command Confirmation Prompting

Rotini will prompt users to confirm (Y/n) commands that have a "force" flag defined in their definition, which can be helpful as a guard against destructive actions. The prompt can be bypassed if the user passes the override flag, which may also be needed in CI/CD environments.

Typed Values

Rotini argument and flag definitions can specify a type, which the parser will respect. Mismatched value types passed to your program will report errors. Additionally, arguments and flags can have defined allowed values and are each provided with a callback for you to write additional validation for your argument and flag parsing.

Value Validators

Each argument and flag has a validator function that can be used to apply additional validation in addition to specifying the value type or known values. Maybe you only want strings of a certain length, or numbers under a certain value - this function provides additional validation behavior control.

Command Operation Handlers

Each rotini command has multiple operation handlers - a beforeHandler, handler, afterHandler, onHandlerSuccess, onHandlerFailure, and onHandlerTimeout function. Only a handler needs to be defined for a command to have an operation, but the other functions can help to control the process flow of your command.

Value Parsers

Each argument and flag has a parser function that can be used to override the parsing that rotini provides. Maybe you want to silently swap any number over a certain value to a known high value, or consistently append to the end of a string - this function provides additional parse behavior control.

Auto-Generated Help Output

Program and Command help output is built from the definition you provide to rotini. When a help flag is passed or when a command syntax is incorrect, rotini will output the corresponding help.

Configuration File Support

Rotini returns helper functions for writing and reading a configuration files for your program that are handed to each command operation handler.

Auto-Update Support

Once published, rotini can check to see when new versions of your CLI are published to a registry and will prompt users to update to the latest version.

Positional Flags

Positional flags are flags that occur as the first parameter passed to your cli program. They differ from global and local flags in that they have an operation handler. When a positional argument is found, flag values will be parsed and handed to the operation.

Global Flags

Global flags exist for every command. If you have a flag that is repeated across all commands, you can define it as a global flag and it will be parsed and provided to any command operation.

Local Flags

Local flags are localized to the command where they are defined and will be found in the resulting command parse object. A local flag might be used over a command argument when it is modifying the behavior of the command.

Shell Autocomplete

Shell autocomplete (bash/zsh) is generated for every program created with rotini. (coming soon)

Dependency Free

Rotini does not have any dependencies. Keeping the bundle size small helps to keep rotini fast at installing, building, and parsing.

Ship Faster

Rotini is a highly-opinionated framework that allows you to focus on your program code without needing to manage how your program is built or parsed.