diff options
author | Chocobozzz <me@florianbigard.com> | 2022-01-18 09:13:36 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-01-18 09:13:36 +0100 |
commit | 4dfd57ae6f7dd2d014c3353111a2428a2288a588 (patch) | |
tree | 08472d6271f86940124e28c03e785e38e09dad04 | |
parent | 5bca1d06200ba99571fead7636bf8dc39a401fe1 (diff) | |
download | PeerTube-4dfd57ae6f7dd2d014c3353111a2428a2288a588.tar.gz PeerTube-4dfd57ae6f7dd2d014c3353111a2428a2288a588.tar.zst PeerTube-4dfd57ae6f7dd2d014c3353111a2428a2288a588.zip |
Better auth args handling for peertube cli
-rw-r--r-- | server/tools/cli.ts | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts index a844b9dcf..7036ae3ec 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts | |||
@@ -73,16 +73,23 @@ function getRemoteObjectOrDie ( | |||
73 | ): { url: string, username: string, password: string } { | 73 | ): { url: string, username: string, password: string } { |
74 | const options = program.opts() | 74 | const options = program.opts() |
75 | 75 | ||
76 | if (!options.url || !options.username || !options.password) { | 76 | const manualOptionMode = options.url || options.username || options.password |
77 | // No remote and we don't have program parameters: quit | 77 | |
78 | if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { | 78 | // Check parameters validity |
79 | if (!options.url) console.error('--url field is required.') | 79 | if (manualOptionMode || settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { |
80 | if (!options.username) console.error('--username field is required.') | 80 | let exit = false |
81 | if (!options.password) console.error('--password field is required.') | 81 | |
82 | 82 | for (const key of [ 'url', 'username', 'password' ]) { | |
83 | return process.exit(-1) | 83 | if (!options[key]) { |
84 | console.error(`--${key} field is required`) | ||
85 | exit = true | ||
86 | } | ||
84 | } | 87 | } |
85 | 88 | ||
89 | if (exit) process.exit(-1) | ||
90 | } | ||
91 | |||
92 | if (!manualOptionMode) { | ||
86 | let url: string = options.url | 93 | let url: string = options.url |
87 | let username: string = options.username | 94 | let username: string = options.username |
88 | let password: string = options.password | 95 | let password: string = options.password |