+ if (exit) process.exit(-1)
+ }
+
+ // If username or password are specified, both are mandatory
+ if (options.username || options.password) {
+ exitIfNoOptions([ 'username', 'password' ])
+ }
+
+ // If no available machines, url, username and password args are mandatory
+ if (Object.keys(netrc.machines).length === 0) {
+ exitIfNoOptions([ 'url', 'username', 'password' ], 'No account found in netrc')
+ }
+
+ if (settings.remotes.length === 0 || settings.default === -1) {
+ exitIfNoOptions([ 'url' ], 'No default instance found')
+ }
+
+ let url: string = options.url
+ let username: string = options.username
+ let password: string = options.password
+
+ if (!url && settings.default !== -1) url = settings.remotes[settings.default]
+
+ const machine = netrc.machines[url]
+ if ((!username || !password) && !machine) {
+ console.error('Cannot find existing configuration for %s.', url)
+ process.exit(-1)
+ }
+
+ if (!username && machine) username = machine.login
+ if (!password && machine) password = machine.password
+
+ return { url, username, password }
+}
+
+function buildCommonVideoOptions (command: Command) {
+ function list (val) {
+ return val.split(',')
+ }
+
+ return command
+ .option('-n, --video-name <name>', 'Video name')
+ .option('-c, --category <category_number>', 'Category number')
+ .option('-l, --licence <licence_number>', 'Licence number')
+ .option('-L, --language <language_code>', 'Language ISO 639 code (fr or en...)')
+ .option('-t, --tags <tags>', 'Video tags', list)
+ .option('-N, --nsfw', 'Video is Not Safe For Work')
+ .option('-d, --video-description <description>', 'Video description')
+ .option('-P, --privacy <privacy_number>', 'Privacy')
+ .option('-C, --channel-name <channel_name>', 'Channel name')
+ .option('--no-comments-enabled', 'Disable video comments')
+ .option('-s, --support <support>', 'Video support text')
+ .option('--no-wait-transcoding', 'Do not wait transcoding before publishing the video')
+ .option('--no-download-enabled', 'Disable video download')
+ .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info')
+}
+
+async function buildVideoAttributesFromCommander (server: PeerTubeServer, command: Command, defaultAttributes: any = {}) {
+ const options = command.opts()
+
+ const defaultBooleanAttributes = {
+ nsfw: false,
+ commentsEnabled: true,
+ downloadEnabled: true,
+ waitTranscoding: true
+ }
+
+ const booleanAttributes: { [id in keyof typeof defaultBooleanAttributes]: boolean } | {} = {}