Skip to content

edit: add --field to edit a single field - #367

Open
NanShanFish wants to merge 5 commits into
doy:mainfrom
NanShanFish:feat/edit-field
Open

edit: add --field to edit a single field#367
NanShanFish wants to merge 5 commits into
doy:mainfrom
NanShanFish:feat/edit-field

Conversation

@NanShanFish

Copy link
Copy Markdown

Feature

Add --field to rbw edit, matching rbw get --field. See #365.

Currently rbw edit can only edit password + notes; this lets users edit a
single field (username, name, notes, password, totp, uris, or a custom field)
from the CLI.

Depends on #366 (editing keyed entries must encrypt with the item key and send
the key field, so this branch is based on that fix).

Changes

  • src/bin/rbw/main.rs: add -f/--field to the Edit subcommand
  • src/bin/rbw/commands.rs:
    • split edit into edit_default (existing password + notes flow) and
      edit_field (single-field flow)
    • edit_field: open the editor with the current plaintext value -> parse via
      parse_field_value -> encrypt with the entry key (org / item key) -> update
      the field -> PUT
    • supported fields: username, name, notes, password (records old password
      into history), totp, uris (one per line, preserving existing per-URI match
      types by plaintext match), custom fields (matched by name substring)
    • empty input clears the field; a clear error is raised for fields that are
      not available on the entry type
  • new parse_field_value helper with unit tests

Usage

rbw edit --field username <entry>                       # editor-based
echo "newuser" | rbw edit --field username <entry>      # non-interactive

Testing

  • cargo test (all targets) passes
  • cargo fmt / cargo clippy --all-targets clean

Fixes #365

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.

rbw edit: support editing a single field (--field)

1 participant