diff options
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r-- | server/tools/cli.ts | 18 |
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 @@ | |||
1 | import { Netrc } from 'netrc-parser' | 1 | import { Netrc } from 'netrc-parser' |
2 | import { getAppNumber, isTestInstance } from '../helpers/core-utils' | 2 | import { getAppNumber, isTestInstance } from '../helpers/core-utils' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { getVideoChannel, root } from '../../shared/extra-utils' | 4 | import { root } from '../../shared/extra-utils/miscs/miscs' |
5 | import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' | ||
5 | import { Command } from 'commander' | 6 | import { Command } from 'commander' |
6 | import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' | 7 | import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' |
7 | 8 | ||
@@ -64,7 +65,11 @@ function deleteSettings () { | |||
64 | }) | 65 | }) |
65 | } | 66 | } |
66 | 67 | ||
67 | function getRemoteObjectOrDie (program: any, settings: Settings, netrc: Netrc) { | 68 | function 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 | ||
169 | function 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 | ||
166 | export { | 178 | export { |
@@ -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 | } |