improve(cli): enhance handleLoadOptions to accept existing options #1811
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Number
#1809
What is the new behavior?
This pull request includes several changes to the
cli
package, focusing on improving the handling of options and adding pre-action hooks to commands. The most important changes include adding tests for saving and loading options, adding pre-action hooks to commands, and updating thehandleLoadOptions
function to merge options correctly.Improvements to option handling:
cli/src/__tests__/utils/options.test.ts
: Added comprehensive tests for saving and loading options for different command types, ensuring that options are correctly persisted and retrieved.cli/src/utils/options.ts
: Updated thehandleLoadOptions
function to merge the current command options with the loaded options, and added thefilterOptions
function to filter options based on their source. [1] [2]cli/src/lib/conn.ts
,cli/src/lib/pub.ts
,cli/src/lib/sub.ts
: Updated thehandleLoadOptions
function calls to include the current command options as a parameter for merging. [1] [2] [3] [4] [5] [6]Command enhancements:
cli/src/index.ts
: Added pre-action hooks to various commands to store the current command globally, allowing options to be filtered based on their source. [1] [2] [3] [4] [5] [6] [7] [8] [9]Type and import improvements:
cli/src/utils/options.ts
: Added type import forOptionValueSource
to improve type safety.Does this PR introduce a breaking change?
Specific Instructions
Are there any specific instructions or things that should be known prior to review?
Other information