Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Command Handlers with Utils.mapArgumentsToOptions #2438

Closed
wants to merge 2 commits into from

Conversation

ATorrise
Copy link
Contributor

@ATorrise ATorrise commented Feb 18, 2025

Previous Code

  • Command handlers used multiple methods and files to map arguments to options.
  • Redundant argument-processing logic increased maintenance complexity.
  • Required the need for **.options.ts files within each cli command handler's directory, increasing the number of files required to interpret the passed-in options.
    image

The Refactor

  • Standardize, condense, and simplify argument mapping with Utils.mapArgumentsToOptions
    • Dynamically map CLI arguments to option keys based on the command definition, removing the need for any **.options.ts files.
    • Allows changes to propagate automatically through the CLI by modifying just the command definition.
    • Replaces Copy.generateDatasetOptions and Create.utils.generateZosmfOptionsBasedOnOptions with mapArgumentsToOptions, consolidating logic.

Impact

  • Reduces redundancy and number of files in the codebase with standardization and centralization.
  • Improves maintainability by allowing future option updates in a single location.

Signed-off-by: Amber <amber.torrise@broadcom.com>
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 75.51020% with 12 lines in your changes missing coverage. Please review.

Project coverage is 91.33%. Comparing base (59b1fc5) to head (030eb74).
Report is 71 commits behind head on master.

Files with missing lines Patch % Lines
packages/cli/src/Utils.ts 67.56% 12 Missing ⚠️

❌ Your patch status has failed because the patch coverage (75.51%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2438      +/-   ##
==========================================
- Coverage   91.37%   91.33%   -0.05%     
==========================================
  Files         639      638       -1     
  Lines       18280    18321      +41     
  Branches     3847     3972     +125     
==========================================
+ Hits        16703    16733      +30     
- Misses       1575     1586      +11     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Amber <amber.torrise@broadcom.com>
@ATorrise
Copy link
Contributor Author

ATorrise commented Feb 19, 2025

poll to either include the utility (1 file) vs utility+implementation (all files).

thumbs up = utility (1 file)
thumbs down = utility+implementation (all files)

@ATorrise ATorrise closed this Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

1 participant