citty icon indicating copy to clipboard operation
citty copied to clipboard

feat: use `undefined` as fallback for `string` & `number` args with no values

Open kricsleo opened this issue 9 months ago • 1 comments

resolves #142

This PR changes the fallback for string & number args from "" to undefined.

This change enables differentiation between user-specified values, such as: test --config vs test --config ""

Example:

  args: {
    name: {
      type: 'string',
    },
    age: {
      type: 'number',
    },
  },

Previously:

test --name => ctx.args.name === "" test --name "" => ctx.args.name === "" test --age => throws

Now:

test --name => ctx.args.name === undefined & ("name" in ctx.args) === true test --name "" => ctx.args.name === ""

test --age => ctx.args.age === undefined & ("age" in ctx.args) === true

kricsleo avatar Apr 08 '25 08:04 kricsleo

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Please upload report for BASE (main@241b948). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #195   +/-   ##
=======================================
  Coverage        ?   94.10%           
=======================================
  Files           ?        7           
  Lines           ?      509           
  Branches        ?      166           
=======================================
  Hits            ?      479           
  Misses          ?       30           
  Partials        ?        0           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Apr 08 '25 08:04 codecov[bot]