2018-05-14 17:15:54 +02:00
|
|
|
import * as program from 'commander';
|
|
|
|
|
|
|
|
import { SyncService } from 'jslib/abstractions/sync.service';
|
|
|
|
|
2018-05-14 20:54:19 +02:00
|
|
|
import { Response } from '../models/response';
|
|
|
|
|
2018-05-14 17:15:54 +02:00
|
|
|
export class SyncCommand {
|
2018-05-14 19:37:52 +02:00
|
|
|
constructor(private syncService: SyncService) { }
|
2018-05-14 17:15:54 +02:00
|
|
|
|
2018-05-14 20:54:19 +02:00
|
|
|
async run(cmd: program.Command): Promise<Response> {
|
2018-05-14 17:15:54 +02:00
|
|
|
try {
|
2018-05-14 20:58:18 +02:00
|
|
|
const result = await this.syncService.fullSync(cmd.force || false);
|
2018-05-14 20:54:19 +02:00
|
|
|
return Response.success();
|
2018-05-14 17:15:54 +02:00
|
|
|
} catch (e) {
|
2018-05-14 20:54:19 +02:00
|
|
|
return Response.success(e.toString());
|
2018-05-14 17:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|