git-annex/doc/git-annex-findkeys.mdwn
Joey Hess f8bc208e89
findkeys: New command, very similar to git-annex find but operating on keys
I've long been asked for `git-annex find --all` or something like that,
but pushed back on it because I feel that the command is analagous to
find(1) and so it would be surprising for it to list keys rather than
files. So instead, add a new findkeys subcommand.

Note that the use of withKeyOptions is rather strange because usually
that is used to fall back to --all rather than listing files, but here
it's made to default to --all like behavior and never list files.

A performance thing that could be improved is that withKeyOptions
always reads and caches location logs. But findkeys with no options does
not need them, so it could be made faster. That caching does speed up
options like --in though. This is really just a subset of a more general
performance thing that --all reads location logs sometimes unncessarily.
Anyway, it needs to read the location log in order to checkDead,
and it seems good that findkeys does skip dead keys.

Also, cleaned up comments on git-annex-find man page asking for --all
option.

Sponsored-by: Dartmouth College's DANDI project
2023-01-17 14:51:57 -04:00

73 lines
1.8 KiB
Markdown

# NAME
git-annex findkeys - lists available keys
# SYNOPSIS
git annex findkeys
# DESCRIPTION
Outputs a list of keys known to git-annex.
# OPTIONS
* matching options
The [[git-annex-matching-options]](1)
can be used to specify which keys to list.
By default, the findkeys command only lists keys whose content is
currently present. Specifying any of the matching options will override
this default behavior and match on all keys that git-annex knows about.
To list all keys, present or not, specify `--anything`.
To list keys whose content is not present, specify `--not --in=here`
* `--print0`
Output keys terminated with nulls, for use with `xargs -0`
* `--format=value`
Use custom output formatting.
The value is a format string, in which '${var}' is expanded to the
value of a variable. To right-justify a variable with whitespace,
use '${var;width}' ; to left-justify a variable, use '${var;-width}';
to escape unusual characters in a variable, use '${escaped_var}'
These variables are available for use in formats: key, backend,
bytesize, humansize, keyname, hashdirlower, hashdirmixed, mtime (for
the mtime field of a WORM key).
Also, '\\n' is a newline, '\\000' is a NULL, etc.
The default output format is the same as `--format='${key}\\n'`
* `--json`
Output the list of keys in JSON format.
This is intended to be parsed by programs that use
git-annex. Each line of output is a JSON object.
* `--json-error-messages`
Messages that would normally be output to standard error are included in
the json instead.
* Also the [[git-annex-common-options]](1) can be used.
# SEE ALSO
[[git-annex]](1)
[[git-annex-find]](1)
# AUTHOR
Joey Hess <id@joeyh.name>
Warning: Automatically converted into a man page by mdwn2man. Edit with care.