Skip to content

Lesson 5: The terminal UI tour

Goal. Drive a whole project from apic ui without touching the command line: run, read, check, edit, reload.

  • apic installed (lesson 1)
  • apic demo running in another terminal, or start it now:
Terminal window
apic demo --out apic-demo
  • A terminal at least 70 columns by 16 rows. The UI says so if it is smaller.

This lesson has no commands to copy after the first one: every step is a key. Keep the page beside the terminal.

Terminal window
apic ui -C apic-demo

apic ui on the demo project

Four areas. Requests on the left, grouped by file, one row per request. On the right, a tab strip with preview, response, checks, session and history. The status bar at the bottom shows the project root, the environment, and the result of the last run. Nothing is different from the command line underneath: the same runner, the same session file, the same environment files. What you see here is what CI sees.

If it refuses to start, that is by design: apic ui is the one interactive command, and it declines a pipe or --json rather than leave a script waiting on a screen. Everything else in apic is non-interactive.

Every row starts with a mark:

MarkMeaning
●Ready: every variable it needs resolves
○Not ready: something is missing, usually a token another request captures
✓Ran and passed every assertion and capture
✗Ran and failed, or could not be sent
spinnerIn flight

On a fresh session most of todos.http is ○: those requests need {{token}} and nothing has captured one yet. whoami is ● even so, because its # @ref login promises to fetch it. Move the cursor with j and k (or the arrows) and watch the preview tab follow: it is apic describe for the selected request, with every variable and where it came from, and the missing ones called out with the request that would provide them.

Put the cursor on login and press enter. The row shows a spinner, then ✓ 200 1ms, and the right pane switches to the response tab: status line, body pretty-printed and highlighted, the assertion that passed, the value captured. Look left again: list-todos, list-open-todos, create-todo and create-todo-invalid have gone from ○ to ●. The token landed in the session and the marks updated without a reload. The rows in between stay ○ for now: get-todo and its neighbours also need todoId, which only create-todo captures, and the flow in the next step is where you see those flip. That is lesson 3 happening in front of you.

Press H to add the request and response headers to the response tab, and again to hide them. Press c to swap the response for the equivalent curl command, ready to paste; press it again for HTTPie, PowerShell, Python, JavaScript and Go, and esc brings the response back.

Move down into todos.http and press f: run every request in the file the cursor is in, in order, as a flow. The rows light up one after another, each turning ✓ or ✗ as its response lands, and the file heading rolls them up: todos.http ✓11 ✗1. The ✗ is not-found, the request that fails on purpose; the flow carries on past it in the UI so you can see the whole file.

The status bar says last: 1 failed, 11 passed. a does the same for the whole project.

With the cursor on not-found, press 3 for the checks tab. It lists each assertion with its actual and expected values side by side:

✗ status == 200
actual 404
expected 200

For a long response, J and K scroll the right pane a line at a time, ctrl+d and ctrl+u half a page, and the right end of the tab strip says where you are: top ↓, ↑ 40% ↓, ↑ end. Scrolling stays put when a later step of a flow lands underneath you; moving to another request starts at the top again.

Press 4. The session tab lists the values captured for the current environment: token, todoId, todoTitle, exactly what apic session prints and what the next apic run will use. x clears them, after a confirmation. Do it, and watch todos.http go back to ○. Then press enter on login again.

  • / filters the list as you type, by id, URL, method, file or description. Type todo, move through the matches with ↓ and ↑, press enter to keep the filter, and esc to clear it.
  • e switches to the next environment and E to the previous one. The project is rebuilt with that environment’s variables and session, and the results on screen are cleared, because they came from somewhere else. If you did lesson 2’s exercise, staging is one press away.
  • o opens the selected request’s file at its line in $VISUAL, then $EDITOR (vi if neither is set, notepad on Windows). Save and quit, and the project is reloaded: a new request appears in the list, a changed assertion runs next time. r reloads without editing, for files changed by anything else.
  • ? shows every key. q quits.

Started with --redact, the UI masks bodies, header values, query values and captures on screen exactly as apic run --redact does, and shows a redact badge in the status bar so a screenshot never hides that values were masked. --demo shows a demo badge the same way.

Press g to go to the top, move onto any request in todos.http, and press f. When the flow finishes, the file heading reads todos.http ✓11 ✗1, the ✗ row is not-found, and the status bar says last: 1 failed, 11 passed. If it does, you have run, read and checked a flow without leaving the UI.

Without quitting the UI, give health in explore.http a fourth assertion, body.$.service == apic-demo, and see it pass.

Solution

Move the cursor onto health, press o, and the file opens at line 7 in your editor. Add the line under the other assertions:

# @assert body.$.version exists
# @assert body.$.service == apic-demo
GET {{baseUrl}}/health

Save and quit. The UI reloads the project. Press enter on health, then 3: four checks, four ✓. If your editor is not what you expected, set EDITOR before starting the UI, for example EDITOR=nano apic ui -C apic-demo.

Episode script

Length. 8 minutes, almost entirely screen.

Cold open (0:00). The UI opening on the demo, cursor on login, todos.http all ○. “Every request in the project, and whether it can run right now. Watch what one key does.”

Talking points.

  1. The four areas and the marks. Move the cursor; the preview follows.
  2. enter on login: the response tab, and the ○ marks flipping to ● on the left. Pause on that.
  3. H and c on the response.
  4. f on todos.http: rows lighting up in order, the file heading rolling up ✓11 ✗1.
  5. 3 on not-found: actual versus expected.
  6. 4, x, marks back to ○, login again.
  7. /, e, o with the exercise edit live, r, ?.
  8. --redact badge; why it refuses pipes and --json.

Shot list. One terminal, 112x30, font size 16, nothing else on screen. docs/learn/tapes/05.tape drives everything except the editor round trip in step 7, which is recorded by hand because the editor is the viewer’s own; it is docs/assets/demo.tape extended with the session, filter and environment flows.

Chapters. 0:00 One key · 0:40 The screen and the marks · 1:40 Run one · 2:40 Run a file · 3:50 Read a failure · 4:50 The session · 5:40 Find, switch, edit, reload · 7:10 Checkpoint and exercise.

Description. From the episode template.

Hosted on Cloudflare, which keeps aggregate traffic statistics. No cookies, no tracking scripts, no per-request logs. Privacy