feat(schema): Enhance argument and option schema with default values, validation, and advanced options#18
Conversation
… validation, and advanced options This commit expands the capabilities for defining CLI arguments and options by introducing several new properties and a dedicated `default` object structure. The `default` object is now available for both `argument` and `option` definitions. It allows specifying default values using one of three methods: a literal `value`, a `fromConfig` path to retrieve a value from a configuration file, or a dynamic `fn` (JavaScript arrow function). Key enhancements for `option` objects include: - `arguments`: Allows defining arguments that can be associated with a specific option. - `choices`: Provides a mechanism to restrict an option's value to a predefined list, aiding in validation. - `range`: Enables specifying a numerical minimum and maximum for an option's value, useful for numeric types. - `required`: A boolean flag to indicate if an option is mandatory. - `variadic`: A boolean flag to allow an option to accept multiple values. Furthermore, properties within the `cli` and `command` object documentation have been reordered for improved clarity and logical grouping.
Summary of ChangesHello @ioncakephper, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the schema definition capabilities for CLI arguments and options. The primary goal is to provide more robust and flexible ways to define default values, validate inputs, and structure command-line interfaces. These changes empower developers to create more sophisticated and user-friendly CLI tools by offering richer configuration and validation options directly within the schema. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request does a good job of updating the README.md to document several new schema features. The new documentation is clear, and reordering existing tables alphabetically is a nice improvement for readability. I've left one comment suggesting an improvement for consistency.
However, it's important to note that this PR only contains changes to the README.md file. The actual implementation of the new schema properties and validation logic described in the PR description and the updated README seems to be missing. If this is intended to be a documentation-only PR, it might be better to align the PR title and description accordingly. If the implementation is meant to be included, it appears to have been omitted from the commit.
| | `value` | `string`, `number`, `boolean`, `array`, `object` | A literal value to use as the default. | | ||
| | `fromConfig` | `string` | A dot-notation path to retrieve a value from a configuration file (e.g., `user.name`). | | ||
| | `fn` | `string` | A JavaScript arrow function that returns the default value. The `program` object is available as an argument. | |
There was a problem hiding this comment.
For consistency with the other property tables in this document (e.g., for cli, command, option), which are sorted alphabetically, it would be best to also sort the properties in the default object table. This improves readability and makes the documentation structure more predictable.
| | `value` | `string`, `number`, `boolean`, `array`, `object` | A literal value to use as the default. | | |
| | `fromConfig` | `string` | A dot-notation path to retrieve a value from a configuration file (e.g., `user.name`). | | |
| | `fn` | `string` | A JavaScript arrow function that returns the default value. The `program` object is available as an argument. | | |
| | `fn` | `string` | A JavaScript arrow function that returns the default value. The `program` object is available as an argument. | | |
| | `fromConfig` | `string` | A dot-notation path to retrieve a value from a configuration file (e.g., `user.name`). | | |
| | `value` | `string`, `number`, `boolean`, `array`, `object` | A literal value to use as the default. | |
This commit expands the capabilities for defining CLI arguments and options by introducing several new properties and a dedicated
defaultobject structure.The
defaultobject is now available for bothargumentandoptiondefinitions. It allows specifying default values using one of three methods: a literalvalue, afromConfigpath to retrieve a value from a configuration file, or a dynamicfn(JavaScript arrow function).Key enhancements for
optionobjects include:arguments: Allows defining arguments that can be associated with a specific option.choices: Provides a mechanism to restrict an option's value to a predefined list, aiding in validation.range: Enables specifying a numerical minimum and maximum for an option's value, useful for numeric types.required: A boolean flag to indicate if an option is mandatory.variadic: A boolean flag to allow an option to accept multiple values.Furthermore, properties within the
cliandcommandobject documentation have been reordered for improved clarity and logical grouping.