Skip to content

Add a standalone, CI-run example program for each core capability #84

Open

Description

@tony

Summary

The docs site's Core API showcase (libtmux/docs#243) shows, per capability, a complete example program next to a list of capabilities. It shows a capability for a port only when that port has a program that qualifies, so today this port shows few or none:

  1. Navigate tmux via a typed object graph
  2. Watch for changes
  3. Send keys
  4. Run applications (where the port has a run-to-exit API)
  5. Rename windows
  6. Create windows
  7. Move windows
  8. Set layouts

Motivation

A reader copies the example, so it has to build and run as shown, and its CI run has to prove it. Excerpts of larger files and test helpers do not qualify.

Current state: Not yet audited against the rule below. The read-only audit of 2026-11-01 lists this port's APIs and examples per capability; each candidate needs checking against the rule.

Proposal

For each capability the library supports, add one small program under the repository's examples that:

  • is a whole file with its imports or use lines, its entry point and its own server setup on a private socket, and no helper defined elsewhere in the repository;
  • does one capability and prints or asserts its outcome, for example the captured line after sending keys, or the new window's name after a rename;
  • runs in CI on a supported tmux, failing on a non-zero exit or a missing expected line, and states its tmux floor where the capability needs one;
  • stays under about 150 lines.

The docs site reads each program whole at the pinned revision; a program it cannot verify is left out rather than excerpted.

References

Installed control-mode example

A candidate vote-counter program starts a private server, opens a pane watch, sends three votes to an awk process and awaits the child's tally after each vote. Running it from outside the checkout with the locally built rock on Lua 5.5.1 produced this output on native tmux 3.7 and 3.8.

no -> yes=0 no=1
yes -> yes=1 no=1
no -> yes=1 no=2

The installed example suite with this candidate passed all 17 programs on each release. It exercises both sending input and reading a fresh application response. The candidate still needs a published program path and inclusion in the hosted example gate for those two showcase entries. The existing pane-watch example supplies the public operations. Pane watch example

Numbered package and Core examples

The private 0.1.2-1 package check ran 23 complete examples on tmux 3.8 and 20 on tmux 3.3a. The three skipped on 3.3a need control mode from tmux 3.7. The local Core and landing pages also rendered and ran all eight Lua capabilities. Publishing all eight depends on an available public Lua revision and its passing trunk checks. Website PR · Showcase acceptance

Activity

  1. added
    p2
    documentation
    enhancement
    area:examples
    topic:examples
    lua
    on Dec 3, 2026
  2. tony commented on Dec 5, 2026

    @tony
    ContributorAuthor

    Draft PR 151 gives the watch and send-keys showcase a runnable calculator. The standalone program drives a real tmux pane, prints 19 + 23 = 42, and checks the same answer from Neovim. Its package test substitutes a wrong answer and a silent program so an echo alone cannot pass. Standalone example

  3. tony commented on Dec 5, 2026

    @tony
    ContributorAuthor

    The vote counter runs the work in a real tmux pane, sends votes and reads the count through control mode. Running it with no yes no produced one yes vote and two no votes. The separate window examples cover navigation, moves and layout changes. The website can pin those sources when the native programs have landed. Window examples.

    Pull request #181.

    On the published vote branch, run lua examples/api/vote_counter.lua no yes no with tmux 3.7 or newer on PATH. It printed yes=1 no=2 on tmux 3.7 with Lua 5.1.5 and on tmux 3.8 with Lua 5.5.1. The three published window examples also ran with PATH alone on tmux 3.3a and 3.8. An absolute TMUX_BIN still selects a particular executable. Vote counter · Window examples.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:examplesdocumentationenhancementluap2topic:examples

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions