mirror of
https://github.com/immich-app/immich.git
synced 2025-01-22 11:42:46 +01:00
f0bb50b61a
* fix: don't allow floating promises * fix: await all promises * fix: download archives * fix cli tests * fix: skip web
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { program, Option } from 'commander';
|
|
import Upload from './commands/upload';
|
|
import ServerInfo from './commands/server-info';
|
|
import LoginKey from './commands/login/key';
|
|
|
|
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(
|
|
new Option('-n, --dry-run', "Don't perform any actions, just show what will be done")
|
|
.env('IMMICH_DRY_RUN')
|
|
.default(false),
|
|
)
|
|
.addOption(new Option('--delete', 'Delete local assets after upload').env('IMMICH_DELETE_ASSETS'))
|
|
.argument('[paths...]', 'One or more paths to assets to be uploaded')
|
|
.action(async (paths, options) => {
|
|
options.excludePatterns = options.ignore;
|
|
await new Upload().run(paths, options);
|
|
});
|
|
|
|
program
|
|
.command('import')
|
|
.description('Import existing assets')
|
|
.usage('[options] [paths...]')
|
|
.addOption(new Option('-r, --recursive', 'Recursive').env('IMMICH_RECURSIVE').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),
|
|
)
|
|
.addOption(new Option('-i, --ignore [paths...]', 'Paths to ignore').env('IMMICH_IGNORE_PATHS').default(false))
|
|
.addOption(new Option('--no-read-only', 'Import files without read-only protection, allowing Immich to manage them'))
|
|
.argument('[paths...]', 'One or more paths to assets to be imported')
|
|
.action(async (paths, options) => {
|
|
options.import = true;
|
|
options.excludePatterns = options.ignore;
|
|
await new Upload().run(paths, options);
|
|
});
|
|
|
|
program
|
|
.command('server-info')
|
|
.description('Display server information')
|
|
|
|
.action(async () => {
|
|
await new ServerInfo().run();
|
|
});
|
|
|
|
program
|
|
.command('login-key')
|
|
.description('Login using an API key')
|
|
.argument('[instanceUrl]')
|
|
.argument('[apiKey]')
|
|
.action(async (paths, options) => {
|
|
await new LoginKey().run(paths, options);
|
|
});
|
|
|
|
program.parse(process.argv);
|