X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fcli.ts;h=d5416fc3870a8e24291881f1c8090a411deb10da;hb=2f03d6dc5e1ff6a8f28cba566f56e72bfb9f3fc8;hp=d1a631b69efbde489f49722689eb7e340f6d65fa;hpb=134cf2bce96a8c5aefd55154e884964975d8cf23;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/cli.ts b/server/tools/cli.ts index d1a631b69..d5416fc38 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -3,7 +3,7 @@ import { getAppNumber, isTestInstance } from '../helpers/core-utils' import { join } from 'path' import { root } from '../../shared/extra-utils/miscs/miscs' import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' -import { Command } from 'commander' +import { CommanderStatic } from 'commander' import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' import { createLogger, format, transports } from 'winston' import { getMyUserInformation } from '@shared/extra-utils/users/users' @@ -35,19 +35,17 @@ interface Settings { default: number } -function getSettings () { - return new Promise((res, rej) => { - const defaultSettings = { - remotes: [], - default: -1 - } +async function getSettings (): Promise { + const defaultSettings = { + remotes: [], + default: -1 + } - config.read((err, data) => { - if (err) return rej(err) + const data = await config.read() - return res(Object.keys(data).length === 0 ? defaultSettings : data) - }) - }) + return Object.keys(data).length === 0 + ? defaultSettings + : data } async function getNetrc () { @@ -62,24 +60,12 @@ async function getNetrc () { return netrc } -function writeSettings (settings) { - return new Promise((res, rej) => { - config.write(settings, err => { - if (err) return rej(err) - - return res() - }) - }) +function writeSettings (settings: Settings) { + return config.write(settings) } function deleteSettings () { - return new Promise((res, rej) => { - config.trash((err) => { - if (err) return rej(err) - - return res() - }) - }) + return config.trash() } function getRemoteObjectOrDie ( @@ -118,7 +104,7 @@ function getRemoteObjectOrDie ( } } -function buildCommonVideoOptions (command: Command) { +function buildCommonVideoOptions (command: CommanderStatic) { function list (val) { return val.split(',') } @@ -133,13 +119,14 @@ function buildCommonVideoOptions (command: Command) { .option('-d, --video-description ', 'Video description') .option('-P, --privacy ', 'Privacy') .option('-C, --channel-name ', 'Channel name') - .option('-m, --comments-enabled', 'Enable comments') + .option('--no-comments-enabled', 'Disable video comments') .option('-s, --support ', 'Video support text') - .option('-w, --wait-transcoding', 'Wait transcoding before publishing the video') + .option('--no-wait-transcoding', 'Do not wait transcoding before publishing the video') + .option('--no-download-enabled', 'Disable video download') .option('-v, --verbose ', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') } -async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any = {}) { +async function buildVideoAttributesFromCommander (url: string, command: CommanderStatic, defaultAttributes: any = {}) { const defaultBooleanAttributes = { nsfw: false, commentsEnabled: true, @@ -227,7 +214,6 @@ function getLogger (logLevel = 'info') { export { version, - config, getLogger, getSettings, getNetrc,