onyo new

Create new ASSETs and populate with KEY-VALUE pairs. Destination directories are created if they are missing.

Asset contents are populated in a waterfall pattern and can overwrite values from previous steps:

  1. --clone or --template

  2. --tsv

  3. --keys

  4. --edit (i.e. manual user input)

The KEYs that comprise the asset filename are required (configured by onyo.assets.name-format).

The contents of all new assets are checked for validity before committing.

RESERVED KEYS:

Some key names are reserved, and are not stored as keys in asset contents:

  • directory: directory to create the asset in relative to the root of the repository. This key cannot be used with the --directory flag.

  • is_asset_directory: whether to create the asset as an Asset Directory. Default is false.

  • template: which template to use for the asset. This key cannot be used with the --clone or --template flags.

usage: onyo new [-h] [-c CLONE] [-t TEMPLATE] [-tsv TSV] [-k KEY [KEY ...]]
                [-e] [-d DIRECTORY] [-m MESSAGE]

Named Arguments

-c, --clone

Path of an asset to clone.

This cannot be used with the --template flag nor the template Reserved Key.

-t, --template

Path to a template to populate the contents of new assets. Relative paths will first attempt to resolve relative the to the template directory (i.e. just the template name), otherwise it will resolve relative to the current working directory.

This cannot be used with the --clone flag nor the template Reserved Key.

-tsv, --tsv

Path to a TSV file describing new assets.

The header declares the key names to be populated. The values to populate assets are declared with one line per asset.

-k, --keys

KEY-VALUE pairs to populate content of new assets.

Each KEY can be defined either 1 or N times (where N is the number of assets to be created). A KEY that is declared once will apply to all new assets, otherwise each will be applied to each new asset in the order they were declared.

For example, create three new laptops with different serials: ` $ onyo new --keys type=laptop make=apple model=macbookpro serial=1 serial=2 serial=3 --directory shelf/ `

Shell brace-expansion makes this even more succinct: ` $ onyo new --keys type=laptop make=apple model=macbookpro serial={1,2,3} --directory shelf/ `

Dictionary subkeys can be addressed using a period (e.g. model.name, model.year, etc.)

-e, --edit

Open new assets in an editor.

Default: False

-d, --directory

Directory to create new assets in.

This cannot be used with the directory Reserved Key.

-m, --message

Use the given MESSAGE as the commit message (rather than the default). If multiple --message options are given, their values are concatenated as separate paragraphs.

Examples

Add three new assets, using an existing asset as a template:

$ onyo new --clone accounting/Bingo Bob/laptop_apple_macbook.oiw629 \
       --keys serial={xyz123,xyz456,xyz789} --directory warehouse/

Add a new asset using a template and open with an editor:

$ onyo new --edit --template laptop_lenovo --directory warehouse/
<spawns editor>

Add three new assets in different locations, and overwrite the default commit message:

$ onyo new --keys RAM=16GB display_size=14 \
       type=laptop make=lenovo model=T490s serial=abc123 directory=accounting/Bingo\ Bob
       type=laptop make=apple model=macbookpro serial=abc456 directory=management/Alice\ Wonderland
       type=laptop make=apple model=macbookpro serial=abc789 directory=warehouse
       --message "Devices for new hires were dropshipped"

Reserved keys

Onyo reserves some keys which have a special function when used while creating new assets, either with onyo new --keys or in a tsv table with onyo new --tsv. They can be used multiple times with different values to create multiple new assets at once with a different value for each asset.

directory

The directory key is an alternative to onyo new --directory to specify the location in which to create new assets.

template

The template key is an alternative to onyo new --template to specify which template to use to create new assets.