Skip to content

Add selftest tui commands for manual prompt verification#5208

Merged
pietern merged 6 commits into
mainfrom
selftest-tui
May 8, 2026
Merged

Add selftest tui commands for manual prompt verification#5208
pietern merged 6 commits into
mainfrom
selftest-tui

Conversation

@pietern

@pietern pietern commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a databricks selftest tui group (hidden, like the rest of selftest) with one subcommand per cmdio prompt entry point: prompt, secret, ask, ask-yes-no, select, select-ordered, run-select, spinner, colors. Each runs a single helper with the simplest meaningful inputs; flags layer in customization (e.g. prompt --mask --validate, select-ordered --filter, run-select --rich, spinner --elapsed).

The motivation is twofold: I want to (1) sanity-check prompts on different terminals (iTerm2, Terminal.app, Windows console, VS Code, tmux) without having to construct a real workspace flow, and (2) eyeball the visual diff when a prompt's rendering is modified — both to catch regressions and to demonstrate intentional changes side-by-side.

Fixture data is drawn from the public Databricks docs so the demo looks like content a user would actually encounter.

This pull request and its description were written by Isaac.

Each scenario is a one-shot subcommand under `databricks selftest tui`
that exercises a single cmdio helper with the simplest meaningful inputs;
flags layer in customization. Used for manual visual confirmation across
terminals and to eyeball the visual diff when prompt rendering changes.

Coverage: ask, ask-yes-no, ask-select, prompt (--default, --mask,
--validate), secret, select (--n), select-ordered (--n, --long, --filter),
run-select (--rich, --conditional), spinner (--elapsed), colors.

Fixture data is drawn from the public Databricks docs so the demo looks
like content a user would actually encounter.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 7, 2026 10:09 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 7, 2026 10:09 — with GitHub Actions Inactive
@pietern pietern requested a review from simonfaltum May 7, 2026 10:15
@pietern

pietern commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@simonfaltum Good spot to include the pager as well, later perhaps.

Comment thread cmd/selftest/tui/fixtures.go
Comment thread cmd/selftest/tui/select.go Outdated
Comment thread cmd/selftest/tui/fixtures.go
- Validate --n > 0 in cobra PreRunE (both `select` and `select-ordered`).
  Previously a negative --n flowed into make([]Tuple, 0, n) and panicked.
- Mirror the production cluster picker more faithfully in --rich:
  expose State/Access/Runtime as methods on clusterItem so the templates
  exercise text/template's method-resolution path, and have State() return
  a pre-colored string via cmdio.Green/Red/Blue (matching the
  renderedState cache on libs/databrickscfg/cfgpickers/clusters.go).

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 7, 2026 12:50 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 7, 2026 12:50 — with GitHub Actions Inactive
@pietern pietern requested a review from simonfaltum May 7, 2026 13:06
cmdio.AskSelect is being removed in #5219 (its only caller migrated to
RunSelect with the new HideHelp option), so this scenario would no longer
compile against main once that lands.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 10:14 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 10:14 — with GitHub Actions Inactive
The flag help on `select-ordered` already documents that `--n` is ignored
when `--long` or `--filter` selects its own fixture, but the PreRunE
validator was rejecting `--long --n=0` anyway. Skip the check in those modes.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 10:19 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 10:19 — with GitHub Actions Inactive
Drop the trailing blank line left after removing newAskSelectCmd.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 10:22 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 10:22 — with GitHub Actions Inactive
cmdio.Secret is a tiny wrapper over the same prompt machinery; keeping a
dedicated file for one 13-line function added more navigation overhead
than it saved.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 12:06 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 8, 2026 12:06 — with GitHub Actions Inactive
@pietern pietern merged commit 4a58c0c into main May 8, 2026
21 of 22 checks passed
@pietern pietern deleted the selftest-tui branch May 8, 2026 12:14
denik pushed a commit that referenced this pull request May 20, 2026
## Summary

Adds a `databricks selftest tui` group (hidden, like the rest of
`selftest`) with one subcommand per cmdio prompt entry point: `prompt`,
`secret`, `ask`, `ask-yes-no`, `select`, `select-ordered`, `run-select`,
`spinner`, `colors`. Each runs a single helper with the simplest
meaningful inputs; flags layer in customization (e.g. `prompt --mask
--validate`, `select-ordered --filter`, `run-select --rich`, `spinner
--elapsed`).

The motivation is twofold: I want to (1) sanity-check prompts on
different terminals (iTerm2, Terminal.app, Windows console, VS Code,
tmux) without having to construct a real workspace flow, and (2) eyeball
the visual diff when a prompt's rendering is modified — both to catch
regressions and to demonstrate intentional changes side-by-side.

Fixture data is drawn from the public Databricks docs so the demo looks
like content a user would actually encounter.

This pull request and its description were written by Isaac.
TanishqDatabricks pushed a commit to TanishqDatabricks/cli that referenced this pull request May 22, 2026
…s#5208)

## Summary

Adds a `databricks selftest tui` group (hidden, like the rest of
`selftest`) with one subcommand per cmdio prompt entry point: `prompt`,
`secret`, `ask`, `ask-yes-no`, `select`, `select-ordered`, `run-select`,
`spinner`, `colors`. Each runs a single helper with the simplest
meaningful inputs; flags layer in customization (e.g. `prompt --mask
--validate`, `select-ordered --filter`, `run-select --rich`, `spinner
--elapsed`).

The motivation is twofold: I want to (1) sanity-check prompts on
different terminals (iTerm2, Terminal.app, Windows console, VS Code,
tmux) without having to construct a real workspace flow, and (2) eyeball
the visual diff when a prompt's rendering is modified — both to catch
regressions and to demonstrate intentional changes side-by-side.

Fixture data is drawn from the public Databricks docs so the demo looks
like content a user would actually encounter.

This pull request and its description were written by Isaac.
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.

3 participants