Skip to content

Fix: Use visibility.base consistently in generateHelpNames for .longWithSingleDash#902

Open
AkshatRaj00 wants to merge 1 commit into
apple:mainfrom
AkshatRaj00:fix/help-names-visibility-base-consistency
Open

Fix: Use visibility.base consistently in generateHelpNames for .longWithSingleDash#902
AkshatRaj00 wants to merge 1 commit into
apple:mainfrom
AkshatRaj00:fix/help-names-visibility-base-consistency

Conversation

@AkshatRaj00

Copy link
Copy Markdown

Summary

This PR fixes an inconsistency in generateHelpNames(visibility:) in HelpGenerator.swift where the .longWithSingleDash case used the full visibility description instead of visibility.base, while the .long case correctly used visibility.base.

Fixes #901

The Bug

// BEFORE (inconsistent)
case .long(let helpName):
  return .long("\(helpName)-\(visibility.base)")           // ✅ uses .base
case .longWithSingleDash(let helpName):
  return .longWithSingleDash("\(helpName)-\(visibility)")  // ❌ uses full visibility

The Fix

// AFTER (consistent)
case .long(let helpName):
  return .long("\(helpName)-\(visibility.base)")
case .longWithSingleDash(let helpName):
  return .longWithSingleDash("\(helpName)-\(visibility.base)")  // ✅ now matches .long

Impact

  • One-line change with no API breakage
  • Affects only commands that configure helpNames with .longWithSingleDash at non-default (hidden/private) visibility levels
  • Ensures -help-hidden and --help-hidden use the same suffix generation logic

Testing

Existing tests for help generation should continue to pass. The affected code path is only triggered when:

  1. helpNames includes .longWithSingleDash
  2. visibility.base != .default (i.e., .hidden or .private)

No new tests are broken by this change.

…ithSingleDash

Previously, the `.longWithSingleDash` case used `visibility` (full
description) while the `.long` case correctly used `visibility.base`
when generating non-default help flag names. This inconsistency would
cause `.longWithSingleDash` help names to have a different suffix than
their `.long` counterparts.

Fixes apple#901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Inconsistent visibility string interpolation in generateHelpNames for .longWithSingleDash vs .long names

1 participant