Skip to content

device: add rename subcommand - #94

Merged
moskovich merged 2 commits into
mainfrom
device-rename
Jul 25, 2026
Merged

device: add rename subcommand#94
moskovich merged 2 commits into
mainfrom
device-rename

Conversation

@moskovich

Copy link
Copy Markdown
Contributor

What

Adds ff-cli device rename <name> <new-name> — renames a configured FF1 device as a pure offline config edit. Host, apiKey, topicID, and list position (and therefore default status) are untouched.

Why

There was no direct way to rename a device. The workarounds are both bad:

  • device add --host <host> --name <new> works but requires knowing the host URL (or having the device reachable for mDNS discovery).
  • device remove + device add silently drops the stored apiKey/topicID and loses default ordering.

Names are the primary handle everywhere (-d office, device default office), and the friendly-name prompt invites labels that change when a frame physically moves.

Behavior

  • Matches by name (case-insensitive) or host URL, mirroring device remove/device default — so unnamed legacy entries can be given a name for the first time.
  • Rejects a new name already used by a different device (case-insensitive, so lookups stay unambiguous); a case-only rename of the same device is allowed.
  • No-op (config not rewritten) when the entry already has exactly the requested name.
  • Trims whitespace; rejects empty names.

Testing

  • tests/device-rename.test.ts — unit tests for the pure helper (10 cases).
  • tests/device-rename-cli.test.ts — CLI integration against a temp config.json, modeled on the device default integration test (4 cases).
  • Full npm run check green: 392 tests, format, lint, copy lint.

Rename a configured device offline, in place: host, apiKey, topicID, and
list position (default status) are untouched. Matches by name
(case-insensitive) or host URL like remove/default, so unnamed legacy
entries can be given a name. Rejects names already used by a different
device.

Previously the only rename paths were 'device add --host --name' (needs
the host) or remove+add (silently drops apiKey/topicID and default
ordering).
@moskovich
moskovich merged commit 623d051 into main Jul 25, 2026
6 checks passed
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.

1 participant