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:
--cloneor--template
--tsv
--keys
--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--directoryflag.
is_asset_directory: whether to create the asset as an Asset Directory. Default isfalse.
template: which template to use for the asset. This key cannot be used with the--cloneor--templateflags.
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
--templateflag nor thetemplateReserved 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
--cloneflag nor thetemplateReserved 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
directoryReserved Key.- -m, --message
Use the given MESSAGE as the commit message (rather than the default). If multiple
--messageoptions 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
directorykey is an alternative toonyo new --directoryto specify the location in which to create new assets.
template
The
templatekey is an alternative toonyo new --templateto specify which template to use to create new assets.