lino 1.2.0.pre.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/lib/lino/command_line_builder.rb +24 -8
- data/lib/lino/subcommand_builder.rb +9 -4
- data/lib/lino/utilities.rb +20 -2
- data/lib/lino/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b16e7c984524e7ce0257398bc97285ad46d8f5c9b2d03c9cc46401dc0450a7eb
|
4
|
+
data.tar.gz: 95a88627410a2053dc73c3a1f6df576cf239095e0dd7fe8f9b01d9ad4ccd150f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e50dbc893fcce9d5d8315047a85c86df23fa3a160ec97790c9530e3503b33cab6d05facf73a2a55f05db4b38ca487c86ade98deaa5741d3874ebbdc27f1dd502
|
7
|
+
data.tar.gz: c72b3205a644395b12a3440d16014fdc480814ed6532ac8920d3a4e0af138ae786cfa99c23b04b8586c503f923441b307e86d1b16be702e79da7e51e496df7f8
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lino (1.
|
4
|
+
lino (1.5.0)
|
5
5
|
hamster (~> 3.0)
|
6
6
|
open4 (~> 1.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.0.
|
11
|
+
activesupport (6.0.3.1)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 0.7, < 2)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
tzinfo (~> 1.1)
|
16
|
-
zeitwerk (~> 2.2)
|
16
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
17
17
|
addressable (2.7.0)
|
18
18
|
public_suffix (>= 2.0.2, < 5.0)
|
19
19
|
colored2 (3.1.2)
|
@@ -28,13 +28,13 @@ GEM
|
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
29
|
i18n (1.8.2)
|
30
30
|
concurrent-ruby (~> 1.0)
|
31
|
-
minitest (5.14.
|
31
|
+
minitest (5.14.1)
|
32
32
|
multipart-post (2.1.1)
|
33
33
|
octokit (4.18.0)
|
34
34
|
faraday (>= 0.9)
|
35
35
|
sawyer (~> 0.8.0, >= 0.5.3)
|
36
36
|
open4 (1.3.4)
|
37
|
-
public_suffix (4.0.
|
37
|
+
public_suffix (4.0.5)
|
38
38
|
rake (13.0.1)
|
39
39
|
rake_circle_ci (0.7.0)
|
40
40
|
colored2 (~> 3.1)
|
@@ -57,15 +57,15 @@ GEM
|
|
57
57
|
rspec-core (~> 3.9.0)
|
58
58
|
rspec-expectations (~> 3.9.0)
|
59
59
|
rspec-mocks (~> 3.9.0)
|
60
|
-
rspec-core (3.9.
|
61
|
-
rspec-support (~> 3.9.
|
62
|
-
rspec-expectations (3.9.
|
60
|
+
rspec-core (3.9.2)
|
61
|
+
rspec-support (~> 3.9.3)
|
62
|
+
rspec-expectations (3.9.2)
|
63
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
64
|
rspec-support (~> 3.9.0)
|
65
65
|
rspec-mocks (3.9.1)
|
66
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
67
|
rspec-support (~> 3.9.0)
|
68
|
-
rspec-support (3.9.
|
68
|
+
rspec-support (3.9.3)
|
69
69
|
sawyer (0.8.2)
|
70
70
|
addressable (>= 2.3.5)
|
71
71
|
faraday (> 0.8, < 2.0)
|
@@ -8,7 +8,7 @@ module Lino
|
|
8
8
|
include Lino::Utilities
|
9
9
|
|
10
10
|
class <<self
|
11
|
-
def for_command
|
11
|
+
def for_command(command)
|
12
12
|
CommandLineBuilder.new(command: command)
|
13
13
|
end
|
14
14
|
end
|
@@ -19,13 +19,15 @@ module Lino
|
|
19
19
|
switches: [],
|
20
20
|
arguments: [],
|
21
21
|
environment_variables: [],
|
22
|
-
option_separator: ' '
|
22
|
+
option_separator: ' ',
|
23
|
+
option_quoting: nil)
|
23
24
|
@command = command
|
24
25
|
@subcommands = Hamster::Vector.new(subcommands)
|
25
26
|
@switches = Hamster::Vector.new(switches)
|
26
27
|
@arguments = Hamster::Vector.new(arguments)
|
27
28
|
@environment_variables = Hamster::Vector.new(environment_variables)
|
28
29
|
@option_separator = option_separator
|
30
|
+
@option_quoting = option_quoting
|
29
31
|
end
|
30
32
|
|
31
33
|
def with_subcommand(subcommand, &block)
|
@@ -33,14 +35,22 @@ module Lino
|
|
33
35
|
SubcommandBuilder.for_subcommand(subcommand))))
|
34
36
|
end
|
35
37
|
|
36
|
-
def with_option(switch, value, separator: nil)
|
37
|
-
with(switches: @switches.add({
|
38
|
+
def with_option(switch, value, separator: nil, quoting: nil)
|
39
|
+
with(switches: @switches.add({
|
40
|
+
components: [switch, value],
|
41
|
+
separator: separator,
|
42
|
+
quoting: quoting
|
43
|
+
}))
|
38
44
|
end
|
39
45
|
|
40
46
|
def with_option_separator(option_separator)
|
41
47
|
with(option_separator: option_separator)
|
42
48
|
end
|
43
49
|
|
50
|
+
def with_option_quoting(character)
|
51
|
+
with(option_quoting: character)
|
52
|
+
end
|
53
|
+
|
44
54
|
def with_flag(flag)
|
45
55
|
with(switches: @switches.add({components: [flag]}))
|
46
56
|
end
|
@@ -55,10 +65,15 @@ module Lino
|
|
55
65
|
|
56
66
|
def build
|
57
67
|
components = [
|
58
|
-
map_and_join(@environment_variables) { |var|
|
68
|
+
map_and_join(@environment_variables) { |var|
|
69
|
+
"#{var[0]}=\"#{var[1].to_s.gsub(/"/, "\\\"")}\""
|
70
|
+
},
|
59
71
|
@command,
|
60
|
-
map_and_join(@switches,
|
61
|
-
|
72
|
+
map_and_join(@switches,
|
73
|
+
&(quote_with(@option_quoting) >> join_with(@option_separator))),
|
74
|
+
map_and_join(@subcommands) { |sub|
|
75
|
+
sub.build(@option_separator, @option_quoting)
|
76
|
+
},
|
62
77
|
map_and_join(@arguments, &join_with(' '))
|
63
78
|
]
|
64
79
|
|
@@ -82,7 +97,8 @@ module Lino
|
|
82
97
|
switches: @switches,
|
83
98
|
arguments: @arguments,
|
84
99
|
environment_variables: @environment_variables,
|
85
|
-
option_separator: @option_separator
|
100
|
+
option_separator: @option_separator,
|
101
|
+
option_quoting: @option_quoting
|
86
102
|
}
|
87
103
|
end
|
88
104
|
end
|
@@ -18,18 +18,23 @@ module Lino
|
|
18
18
|
@switches = Hamster::Vector.new(switches)
|
19
19
|
end
|
20
20
|
|
21
|
-
def with_option(switch, value, separator: nil)
|
22
|
-
with(switches: @switches.add({
|
21
|
+
def with_option(switch, value, separator: nil, quoting: nil)
|
22
|
+
with(switches: @switches.add({
|
23
|
+
components: [switch, value],
|
24
|
+
separator: separator,
|
25
|
+
quoting: quoting
|
26
|
+
}))
|
23
27
|
end
|
24
28
|
|
25
29
|
def with_flag(flag)
|
26
30
|
with(switches: @switches.add({components: [flag]}))
|
27
31
|
end
|
28
32
|
|
29
|
-
def build(option_separator)
|
33
|
+
def build(option_separator, option_quoting)
|
30
34
|
components = [
|
31
35
|
@subcommand,
|
32
|
-
map_and_join(@switches,
|
36
|
+
map_and_join(@switches,
|
37
|
+
&(quote_with(option_quoting) >> join_with(option_separator)))
|
33
38
|
]
|
34
39
|
|
35
40
|
components
|
data/lib/lino/utilities.rb
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
1
3
|
module Lino
|
2
4
|
module Utilities
|
3
5
|
def map_and_join(collection, &block)
|
4
6
|
collection.map { |item| block.call(item) }.join(' ')
|
5
7
|
end
|
6
8
|
|
7
|
-
def join_with(
|
8
|
-
lambda
|
9
|
+
def join_with(global_separator)
|
10
|
+
lambda do |item|
|
11
|
+
item[:components].join(item[:separator] || global_separator)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def quote_with(global_character)
|
16
|
+
lambda do |item|
|
17
|
+
character = item[:quoting] || global_character
|
18
|
+
components = item[:components]
|
19
|
+
switch = components[0]
|
20
|
+
value = components[1]
|
21
|
+
|
22
|
+
item.merge(
|
23
|
+
components: (components.count > 1) ?
|
24
|
+
[switch, "#{character}#{value}#{character}"] :
|
25
|
+
components)
|
26
|
+
end
|
9
27
|
end
|
10
28
|
end
|
11
29
|
end
|
data/lib/lino/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
@@ -213,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '2.6'
|
214
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
215
|
requirements:
|
216
|
-
- - "
|
216
|
+
- - ">="
|
217
217
|
- !ruby/object:Gem::Version
|
218
|
-
version:
|
218
|
+
version: '0'
|
219
219
|
requirements: []
|
220
220
|
rubygems_version: 3.0.1
|
221
221
|
signing_key:
|