Skip to content

feat(config): align init/config UX with atlassian-cli patterns#31

Merged
rianjs merged 1 commit intomainfrom
feat/30-align-init-config-ux
Feb 2, 2026
Merged

feat(config): align init/config UX with atlassian-cli patterns#31
rianjs merged 1 commit intomainfrom
feat/30-align-init-config-ux

Conversation

@rianjs
Copy link
Contributor

@rianjs rianjs commented Feb 2, 2026

Summary

Aligns sfdc init and config commands with UX patterns established in atlassian-cli.

Changes

  • Init uses huh forms: Replaced bufio prompts with styled huh form for instance URL and client ID inputs
  • Init pre-populates: Form fields are pre-filled from existing config values
  • OAuth flow preserved: Browser opening and callback server logic unchanged
  • Fixed client ID masking: Changed from first4...last4 to first4********last4

Note: salesforce-cli already had --force flag on config clear and no config set command, so those were already aligned.

Test plan

  • make build passes
  • make test passes
  • make lint passes
  • Manual: sfdc init shows styled form
  • Manual: sfdc config show masks client ID correctly
  • Manual: OAuth flow still works correctly

Closes #30

- Refactor init command to use huh forms for configuration inputs
- Keep OAuth flow and browser opening logic intact
- Pre-populate form fields from existing config values
- Fix client ID masking to use 8 asterisks: first4********last4
- Update tests for new masking format

Closes #30
@rianjs
Copy link
Contributor Author

rianjs commented Feb 2, 2026

Test Coverage Assessment for PR #31

Summary

This PR makes two types of changes:

  1. maskClientID function in configcmd.go - Updated masking logic with new boundary handling and empty string support
  2. runInit function in initcmd/init.go - Replaced bufio prompts with huh form library for interactive input

Coverage Analysis

maskClientID Changes (configcmd.go) - WELL COVERED

The test coverage for the masking function is excellent:

Test Case Status
Empty client ID ("") Covered
Long client ID (>8 chars) Covered
Short client ID (<=8 chars) Covered
Boundary: exactly 8 chars Covered
Boundary: exactly 9 chars Covered

The tests verify the new masking format (first4********last4) and the updated threshold (8 chars instead of 12). All edge cases are properly tested.

runInit Changes (initcmd/init.go) - TESTING GAP EXISTS

The existing tests cover:

  • Command construction (TestNewCommand)
  • Auth code extraction logic (TestExtractAuthCode)
  • Flag registration

Not covered by automated tests:

  • The new huh form integration
  • Form value pre-population from existing config
  • CLI flag priority over config values
  • Form validation (client ID required)
  • Default instance URL application

Mitigating factors:

  1. The huh library is a well-tested third-party library - we're testing their library, not ours
  2. The business logic (config priority: CLI flag > existing config > default) is straightforward
  3. The core OAuth flow (callback server, token exchange, verification) is unchanged
  4. The PR description indicates manual testing was performed
  5. Testing interactive terminal UIs (TUIs) is notoriously difficult and often provides low ROI

Recommendation

Acceptable for merge. The test coverage is pragmatically appropriate:

  • Critical utility function (maskClientID) has comprehensive edge case coverage
  • The huh form is a presentation layer change with manual verification
  • Adding unit tests for the form would require mocking the terminal, which adds complexity with minimal value

If you wanted to improve testability in the future, you could extract the config priority logic into a separate function:

func resolveConfigValue(flagValue, configValue, defaultValue string) string

This would be easily unit-testable, but it's not a blocker for this PR given the straightforward nature of the logic.


Automated review by Claude

@rianjs rianjs merged commit 4770a90 into main Feb 2, 2026
3 checks passed
@rianjs rianjs deleted the feat/30-align-init-config-ux branch February 2, 2026 12:00
@rianjs rianjs mentioned this pull request Feb 2, 2026
2 tasks
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.

Align init/config UX with atlassian-cli patterns

1 participant

Comments