Skip to content

feat(jtk): align init and config UX with cfl#55

Merged
rianjs merged 2 commits intomainfrom
feat/53-jtk-align-init-config-ux
Feb 2, 2026
Merged

feat(jtk): align init and config UX with cfl#55
rianjs merged 2 commits intomainfrom
feat/53-jtk-align-init-config-ux

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Feb 2, 2026

Summary

Aligns jtk's init and config commands with cfl's UX patterns for consistency across Atlassian CLI tools.

Changes

  • init command: Use huh library for styled interactive forms, add optional default project field, reuse existing config values when re-running init
  • config clear: Add --force flag with confirmation by default
  • config show: Add default_project display, standardize token masking to abcd********wxyz format
  • config set: Removed (users should use init for changes)
  • config test: Kept as-is (shows authenticated user details - better than cfl's simple "success!" message)

Test plan

  • make build-jtk succeeds
  • make test in tools/jtk passes
  • make lint in tools/jtk passes
  • Manual test: jtk init shows styled form
  • Manual test: jtk config clear prompts for confirmation
  • Manual test: jtk config clear --force skips confirmation
  • Manual test: jtk config show displays default_project

Closes #53

- Use huh library for styled interactive forms in init command
- Add optional default project field to init and config
- Reuse existing config values when re-running init
- Remove config set command (use init for changes)
- Add --force flag to config clear with confirmation by default
- Standardize token masking to abcd********wxyz format
- Keep config test output showing authenticated user details

Closes #53
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Feb 2, 2026

Test Coverage Assessment

Summary

This PR has good test coverage for the changes made. The critical paths and utility functions are tested, and the acknowledged limitation (huh TTY requirement) is reasonable.

Coverage Analysis

Well Covered

Component Tests Assessment
maskToken() TestMaskToken - 5 cases Excellent coverage of edge cases (empty, short, normal, boundary at 8 chars)
config clear --force TestRunClear_Force Tests that --force skips confirmation
config clear with confirmation TestRunClear_WithConfirmation, TestRunClear_Cancelled Tests both "y" and "n" responses
GetDefaultProject() TestConfig_GetDefaultProject_Env, TestConfig_GetDefaultProject_NoConfig Tests env var precedence and empty case
getDefaultProjectSource() TestGetDefaultProjectSource Tests env vs no-config source display
DefaultProject field in Config TestConfig_DefaultProject Tests JSON serialization/deserialization

Acknowledged Gaps (Acceptable)

Component Reason
runInit() with huh forms The huh library requires a TTY for interactive forms. Testing is done via config save/load verification. This is a reasonable tradeoff documented in the test file.
newShowCmd() output Relies on existing view/rendering infrastructure which has its own tests.

Minor Observations

  1. Environment variable notification in runClear: The code that checks for active env vars after clearing config (lines 379-396 in configcmd.go) isn't explicitly tested. The logic is simple (string concatenation and print), but a test verifying the output when env vars are set would be thorough.

  2. config clear when no file exists: The runClear function handles this case (returns early with info message), but there's no explicit test for this path. The underlying config.Clear() handles this gracefully (tested in TestConfig_Clear_NotExists), so the risk is low.

  3. Pre-fill precedence in runInit: The logic for pre-filling form values (CLI flag > existing config) could benefit from a unit test, but since this flows through to config.Save() which is well-tested, the risk is minimal.

Verdict

Approve from a test coverage perspective. The PR:

  • Tests all new utility functions (maskToken, GetDefaultProject, getDefaultProjectSource)
  • Tests the critical config clear confirmation flow with both positive and negative cases
  • Tests the new DefaultProject config field serialization
  • Acknowledges the TTY limitation for huh forms with a reasonable workaround (testing config save/load separately)

The minor gaps noted above are low-risk and don't warrant blocking the PR.

@rianjs rianjs merged commit bbecd98 into main Feb 2, 2026
7 checks passed
@rianjs rianjs deleted the feat/53-jtk-align-init-config-ux branch February 2, 2026 11:36
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.

[jtk] Align init and config UX with cfl

1 participant