2023-11-19 23:16:24 +01:00
|
|
|
#! /usr/bin/env node
|
|
|
|
|
2023-07-06 16:37:47 +02:00
|
|
|
import { program, Option } from 'commander';
|
|
|
|
import Upload from './commands/upload';
|
|
|
|
import ServerInfo from './commands/server-info';
|
|
|
|
import LoginKey from './commands/login/key';
|
2023-11-19 23:16:24 +01:00
|
|
|
import Logout from './commands/logout';
|
2023-07-06 16:37:47 +02:00
|
|
|
|
|
|
|
program.name('immich').description('Immich command line interface');
|
|
|
|
|
|
|
|
program
|
|
|
|
.command('upload')
|
|
|
|
.description('Upload assets')
|
|
|
|
.usage('[options] [paths...]')
|
|
|
|
.addOption(new Option('-r, --recursive', 'Recursive').env('IMMICH_RECURSIVE').default(false))
|
|
|
|
.addOption(new Option('-i, --ignore [paths...]', 'Paths to ignore').env('IMMICH_IGNORE_PATHS'))
|
|
|
|
.addOption(new Option('-h, --skip-hash', "Don't hash files before upload").env('IMMICH_SKIP_HASH').default(false))
|
|
|
|
.addOption(
|
2023-11-19 23:16:24 +01:00
|
|
|
new Option('-a, --album', 'Automatically create albums based on folder name')
|
|
|
|
.env('IMMICH_AUTO_CREATE_ALBUM')
|
2023-07-06 16:37:47 +02:00
|
|
|
.default(false),
|
|
|
|
)
|
|
|
|
.addOption(
|
|
|
|
new Option('-n, --dry-run', "Don't perform any actions, just show what will be done")
|
|
|
|
.env('IMMICH_DRY_RUN')
|
|
|
|
.default(false),
|
|
|
|
)
|
2023-11-19 23:16:24 +01:00
|
|
|
.addOption(new Option('--delete', 'Delete local assets after upload').env('IMMICH_DELETE_ASSETS'))
|
|
|
|
.argument('[paths...]', 'One or more paths to assets to be uploaded')
|
2023-10-13 07:22:40 +02:00
|
|
|
.action(async (paths, options) => {
|
2023-11-19 23:16:24 +01:00
|
|
|
options.exclusionPatterns = options.ignore;
|
2023-10-13 07:22:40 +02:00
|
|
|
await new Upload().run(paths, options);
|
2023-07-06 16:37:47 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
program
|
|
|
|
.command('server-info')
|
|
|
|
.description('Display server information')
|
2023-10-13 07:22:40 +02:00
|
|
|
.action(async () => {
|
|
|
|
await new ServerInfo().run();
|
2023-07-06 16:37:47 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
program
|
|
|
|
.command('login-key')
|
|
|
|
.description('Login using an API key')
|
|
|
|
.argument('[instanceUrl]')
|
|
|
|
.argument('[apiKey]')
|
2023-10-13 07:22:40 +02:00
|
|
|
.action(async (paths, options) => {
|
|
|
|
await new LoginKey().run(paths, options);
|
2023-07-06 16:37:47 +02:00
|
|
|
});
|
|
|
|
|
2023-11-19 23:16:24 +01:00
|
|
|
program
|
|
|
|
.command('logout')
|
|
|
|
.description('Remove stored credentials')
|
|
|
|
.action(async () => {
|
|
|
|
await new Logout().run();
|
|
|
|
});
|
|
|
|
|
2023-07-06 16:37:47 +02:00
|
|
|
program.parse(process.argv);
|