feat: add --json-output option to upload command (#18845)

* fix(docs): update the cli upload usage

The cli upload usage is missing some options compared to what is the current
output of `immich upload --help`. Update the docs accordingly.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>

* feat(cli): add --json-output option to upload command

Add an option that allows retrieving per-file information about the
upload process. The output includes the newFiles, duplicates and
newAssets lists, but could accommodate more information later if needed.

One use case this allows for is using --dry-run to get a list of all the
files that would be uploaded, and checking them manually before an
upload. This can be particularly useful when a curated subset of images
have already been uploaded to immich and we want to double check for
some stragglers without uploading everything to immich.

The upload command has a few lines of logging, so to get an actually
parsable json one needs to strip those lines:

  immich upload --dry-run * | tail -n +4 | jq .newFiles[]

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>

---------

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
This commit is contained in:
Bence Ferdinandy 2025-06-02 03:58:58 +02:00 committed by GitHub
parent c89ac5b5e5
commit 31af44dd2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 11 deletions

View file

@ -68,6 +68,11 @@ program
.env('IMMICH_UPLOAD_CONCURRENCY')
.default(4),
)
.addOption(
new Option('-j, --json-output', 'Output detailed information in json format')
.env('IMMICH_JSON_OUTPUT')
.default(false),
)
.addOption(new Option('--delete', 'Delete local assets after upload').env('IMMICH_DELETE_ASSETS'))
.addOption(new Option('--no-progress', 'Hide progress bars').env('IMMICH_PROGRESS_BAR').default(true))
.addOption(