@fnet/yargs-options-from-schema
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@fnet/yargs-options-from-schema

@fnet/yargs-options-from-schema is a project designed to seamlessly convert a JSON schema into a format that's suitable for yargs.options, an aspect of the command-line parser library, yargs. The result is a robust and flexible command-line interface configured directly from JSON schema definitions.

Purpose and Functionality

The concept here is making an end-user's interaction with command-line interfaces significantly easier by enabling them to navigate predefined commands and options effectively.

@aftnet/yargs-options-from-schema works by examining the properties of a JSON schema and converting those properties into a set of options that are compatible with yargs functions. This allows an end-user to interact with the system using these yargs-enabled commands from their terminal.

Key Features and Capabilities

  1. An ability to convert JSON schema types to types that yargs understands. Strings, numbers, integers, and booleans are converted, while all other types default to strings.

  2. Support for attribute assignment in the schema properties. Users can assign descriptions, default values, aliases, and more to particular commands.

  3. Value constraints and transformations. The project enables "enum" type of constraints for predefined choice validation. Additionally, it also handles custom value transformations via "coerce" operation.

  4. Advanced attribute assignment. The code supports advanced attributes in JSON schemas, including requiresArg, array, skipValidation, and more.

  5. Local and remote schema loading. The project also includes a function designed to handle both local and remote schema loading.

In conclusion, @fnet/yargs-options-from-schema offers an efficient way to map JSON schema properties to yargs command-line interfaces, enhancing the user experience while using command-line interfaces of applications.

Readme

Keywords

none

Package Sidebar

Install

npm i @fnet/yargs-options-from-schema

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

13.3 kB

Total Files

7

Last publish

Collaborators

  • gboyraz