aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/cli.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r--server/tools/cli.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index 2eec51aa4..67755022c 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -1,7 +1,8 @@
1import { Netrc } from 'netrc-parser' 1import { Netrc } from 'netrc-parser'
2import { getAppNumber, isTestInstance } from '../helpers/core-utils' 2import { getAppNumber, isTestInstance } from '../helpers/core-utils'
3import { join } from 'path' 3import { join } from 'path'
4import { getVideoChannel, root } from '../../shared/extra-utils' 4import { root } from '../../shared/extra-utils/miscs/miscs'
5import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels'
5import { Command } from 'commander' 6import { Command } from 'commander'
6import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' 7import { VideoChannel, VideoPrivacy } from '../../shared/models/videos'
7 8
@@ -64,7 +65,11 @@ function deleteSettings () {
64 }) 65 })
65} 66}
66 67
67function getRemoteObjectOrDie (program: any, settings: Settings, netrc: Netrc) { 68function getRemoteObjectOrDie (
69 program: any,
70 settings: Settings,
71 netrc: Netrc
72): { url: string, username: string, password: string } {
68 if (!program['url'] || !program['username'] || !program['password']) { 73 if (!program['url'] || !program['username'] || !program['password']) {
69 // No remote and we don't have program parameters: quit 74 // No remote and we don't have program parameters: quit
70 if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { 75 if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) {
@@ -161,6 +166,13 @@ async function buildVideoAttributesFromCommander (url: string, command: Command,
161 return videoAttributes 166 return videoAttributes
162} 167}
163 168
169function getServerCredentials (program: any) {
170 return Promise.all([ getSettings(), getNetrc() ])
171 .then(([ settings, netrc ]) => {
172 return getRemoteObjectOrDie(program, settings, netrc)
173 })
174}
175
164// --------------------------------------------------------------------------- 176// ---------------------------------------------------------------------------
165 177
166export { 178export {
@@ -172,6 +184,8 @@ export {
172 writeSettings, 184 writeSettings,
173 deleteSettings, 185 deleteSettings,
174 186
187 getServerCredentials,
188
175 buildCommonVideoOptions, 189 buildCommonVideoOptions,
176 buildVideoAttributesFromCommander 190 buildVideoAttributesFromCommander
177} 191}