onyo edit

Open ASSETs in an editor.

When multiple ASSETs are given, they are opened sequentially.

The editor is selected by (in order):

  • ONYO_CORE_EDITOR environment variable

  • onyo.core.editor configuration option

  • core.editor configuration option (git)

  • EDITOR environment variable

  • nano (as a final fallback)

ONYO_CORE_EDITOR is especially useful to programmatically modify assets with a utility (e.g. sed or jq) or a bespoke script.

The contents of all edited ASSETs are checked for validity before committing. If problems are found, a prompt is offered to either reopen the editor or discard the changes.

usage: onyo edit [-h] [-m MESSAGE] [--no-auto-message] ASSET [ASSET ...]

Positional Arguments

ASSET

Paths of assets to edit.

Named Arguments

-m, --message

Append MESSAGE to the commit message. If multiple --message options are given, their values are concatenated as separate paragraphs.

--no-auto-message

Do not auto-generate the commit message subject. If no MESSAGE is given, the subject line will be [Empty subject]. This does not disable the inventory operations record at the end of a commit message. The default is configured via ‘onyo.commit.auto-message’.

Default: False

Examples

Edit an asset:

$ onyo edit accounting/Bingo\ Bob/laptop_lenovo_T490s.abc123
<spawns editor>

Use sed to rename the key ‘ram’ to ‘RAM’ in all assets:

$ ONYO_CORE_EDITOR="sed -i 's/ram:/RAM:/g'"
$ onyo get --machine-readable --keys onyo.path.relative | xargs -d "\n" onyo --yes edit