aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-06-13 13:59:34 +0200
committerChocobozzz <me@florianbigard.com>2019-06-17 08:16:09 +0200
commit6b226c32782ea7779ced56c1e1090d8b51c5c504 (patch)
tree529c9108d92d26dde650f89b0106b2c15dba79c8
parentb30acc0e4b2cf596704e5949c2d7020eccb7f720 (diff)
downloadPeerTube-6b226c32782ea7779ced56c1e1090d8b51c5c504.tar.gz
PeerTube-6b226c32782ea7779ced56c1e1090d8b51c5c504.tar.zst
PeerTube-6b226c32782ea7779ced56c1e1090d8b51c5c504.zip
Fix CLI default boolean values
-rw-r--r--server/tests/cli/peertube.ts1
-rw-r--r--server/tools/cli.ts13
2 files changed, 11 insertions, 3 deletions
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index 0a8a98334..d73e27564 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -158,6 +158,7 @@ describe('Test CLI wrapper', function () {
158 expect(videoDetails.channel.name).to.equal('user_channel') 158 expect(videoDetails.channel.name).to.equal('user_channel')
159 expect(videoDetails.support).to.equal('support') 159 expect(videoDetails.support).to.equal('support')
160 expect(videoDetails.nsfw).to.be.true 160 expect(videoDetails.nsfw).to.be.true
161 expect(videoDetails.commentsEnabled).to.be.true
161 } 162 }
162 }) 163 })
163 164
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index 4aa3d9ce8..2eec51aa4 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -117,15 +117,22 @@ function buildCommonVideoOptions (command: Command) {
117} 117}
118 118
119async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any) { 119async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any) {
120 const booleanAttributes: { [id: string]: boolean } = {} 120 const defaultBooleanAttributes = {
121 nsfw: false,
122 commentsEnabled: true,
123 downloadEnabled: true,
124 waitTranscoding: true
125 }
126
127 const booleanAttributes: { [id in keyof typeof defaultBooleanAttributes]: boolean } | {} = {}
121 128
122 for (const key of [ 'nsfw', 'commentsEnabled', 'downloadEnabled', 'waitTranscoding' ]) { 129 for (const key of Object.keys(defaultBooleanAttributes)) {
123 if (command[ key ] !== undefined) { 130 if (command[ key ] !== undefined) {
124 booleanAttributes[key] = command[ key ] 131 booleanAttributes[key] = command[ key ]
125 } else if (defaultAttributes[key] !== undefined) { 132 } else if (defaultAttributes[key] !== undefined) {
126 booleanAttributes[key] = defaultAttributes[key] 133 booleanAttributes[key] = defaultAttributes[key]
127 } else { 134 } else {
128 booleanAttributes[key] = false 135 booleanAttributes[key] = defaultBooleanAttributes[key]
129 } 136 }
130 } 137 }
131 138