Skip to content

Commit 44dd150

Browse files
authored
Merge pull request #3 from rickdrumond/feat/repeatable-options
Add repeatable options through array values
2 parents 2579729 + c51dd15 commit 44dd150

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
ytdl (0.4.0)
4+
ytdl (0.4.1)
55
dry-configurable (~> 1.0)
66
filesize (~> 0.2.0)
77

@@ -25,4 +25,4 @@ DEPENDENCIES
2525
ytdl!
2626

2727
BUNDLED WITH
28-
2.4.20
28+
2.6.8

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ Options passed to `YoutubeDL.download` get transformed as follows:
7474
* `some_option: true` becomes `--some-option`
7575
* `some_option: false` becomes `--no-some-option`
7676
* `some_option: 'anything'` becomes `--some-option anything`
77+
* `some_option: ['any', 'thing']` becomes `--some-option any --some-option thing`
7778
* `some_option: nil` can be used to remove a default option

lib/youtube_dl/command.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ def arguments
3333
when [] then nil
3434
when true then "--#{option}"
3535
when false then "--no-#{option}"
36-
else ["--#{option}", value]
36+
else
37+
# Handle array values by repeating the option.
38+
#
39+
# Example: { paths: ['temp:/tmp', '/complete'] }
40+
# Becomes: ['--paths', 'temp:/tmp', '--paths', '/complete']
41+
#
42+
# Example: { paths: '/downloads' }
43+
# Becomes: ['--paths', '/downloads]
44+
[*value].flat_map { |v| ["--#{option}", v] }
3745
end
3846
end
3947
end

lib/youtube_dl/output_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'filesize'
2+
require 'pathname'
23
require 'youtube_dl/state'
34

45
module YoutubeDL

lib/youtube_dl/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module YoutubeDL
2-
VERSION = "0.4.0"
2+
VERSION = "0.4.1"
33
end

0 commit comments

Comments
 (0)