Files
speckle-server/packages/server/modules/cli/commands/stream/clone.ts
T
Kristaps Fabians Geikins b02a07e2b6 feat: Frontend 2.0 MVP
2023-05-08 10:47:01 +03:00

32 lines
977 B
TypeScript

import { cloneStream } from '@/modules/core/services/streams/clone'
import { cliLogger } from '@/logging/logging'
import { CommandModule } from 'yargs'
const command: CommandModule<
unknown,
{ sourceStreamId: string; targetUserId: string }
> = {
command: 'clone <sourceStreamId> <targetUserId>',
describe: 'Clone a source stream to the account of the target user',
builder: {
sourceStreamId: {
describe: 'ID of the stream that will be cloned',
type: 'string'
},
targetUserId: {
describe: 'ID of the user who will be marked as the author of the cloned stream',
type: 'string'
}
},
handler: async (argv) => {
const { sourceStreamId, targetUserId } = argv
cliLogger.info(
`Cloning stream ${sourceStreamId} into the account of user ${targetUserId}...`
)
const { id } = await cloneStream(targetUserId, sourceStreamId)
cliLogger.info('Cloning successful! New stream ID: ' + id)
}
}
export = command