Skip to content

Add device-aware CLI, devices command, completion scripts, and connect wait/retry#159

Draft
shazow wants to merge 1 commit intomainfrom
codex/implement-cli-enhancements-and-documentation
Draft

Add device-aware CLI, devices command, completion scripts, and connect wait/retry#159
shazow wants to merge 1 commit intomainfrom
codex/implement-cli-enhancements-and-documentation

Conversation

@shazow
Copy link
Copy Markdown
Owner

@shazow shazow commented Mar 15, 2026

Motivation

  • Provide a way to target a specific wireless interface from the CLI and surface available interfaces for scripting and shell completion.
  • Let connect optionally wait for an SSID to appear and retry until timeout so non-interactive scripts can robustly connect to networks that appear shortly after invocation.
  • Expose device enumeration in the backend abstraction so platform implementations (NetworkManager/iwd/darwin) and the mock backend can expose and be tested for device selection.

Description

  • Add a global --device option (in Options) and call configureBackendDevice() from each command handler to apply the selected device via Backend.SetDevice before operations.
  • Extend the backend API with a Device model and two methods: ListDevices() ([]Device, error) and SetDevice(name string) error in wifi/backend.go, and implement them in wifi/networkmanager, wifi/iwd, wifi/darwin, and wifi/mock.
  • Implement wifitui devices (runDevices) that by default prints stable, line-separated device names and supports --json to emit richer metadata such as name, type, state, backend, and optional details.
  • Add shell completion generation (wifitui completion <bash|zsh|fish>) and completed scripts that dynamically source --device values from wifitui devices and SSID suggestions for connect from wifitui list --all --scan.
  • Add connect retry/wait behavior: new --retry parsing (DURATION[:INTERVAL]) and --wait to enable "require visible" semantics so connect will rescan and retry until the SSID appears or timeout; updated runConnect/attemptConnect to emit visibility-specific retry messages.
  • Update mock backend to expose multiple devices and implement ListDevices/SetDevice for deterministic tests, and adjust platform backends to enumerate/select devices where applicable.
  • Update CLI parsing and defaults (main.go / cli.go) and add new/changed tests for CLI parsing, device routing, device command behavior, and connect retry/wait semantics in cli_test.go and wifi/mock/mock_test.go, and document usage examples in README.md.

Testing

  • Updated and added unit tests were run with go test ./... and all tests passed successfully.
  • New/changed tests include CLI parsing and behavior (cli_test.go) and mock backend device tests (wifi/mock/mock_test.go) and exercised connect retry/wait behavior with simulated backends.
  • Manual validation was performed by running the generated shell completion outputs and the new devices and connect --wait flows in tests (captured by the automated tests above).

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant