clasp-ruby 0.23.0.2 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/cr-example.rb +16 -16
- data/examples/flag_and_option_specifications.rb +15 -15
- data/examples/show_usage_and_version.rb +10 -11
- data/lib/clasp/arguments.rb +86 -87
- data/lib/clasp/clasp.rb +15 -11
- data/lib/clasp/cli.rb +135 -134
- data/lib/clasp/old_module.rb +8 -8
- data/lib/clasp/specifications.rb +325 -322
- data/lib/clasp/util/exceptions.rb +21 -22
- data/lib/clasp/util/value_parser.rb +99 -101
- data/lib/clasp/version.rb +12 -12
- data/lib/clasp-ruby.rb +8 -7
- data/lib/clasp.rb +8 -7
- data/test/scratch/test_list_command_line.rb +6 -6
- data/test/scratch/test_specifications.rb +14 -14
- data/test/scratch/test_usage.rb +5 -5
- data/test/scratch/test_usage_with_duplicate_specifications.rb +5 -5
- data/test/unit/tc_ARGV_rewrite.rb +36 -36
- data/test/unit/tc_arguments_1.rb +708 -708
- data/test/unit/tc_arguments_2.rb +43 -43
- data/test/unit/tc_arguments_3.rb +77 -77
- data/test/unit/tc_arguments_inspect.rb +55 -55
- data/test/unit/tc_cli.rb +4 -4
- data/test/unit/tc_default_value.rb +91 -91
- data/test/unit/tc_defaults_1.rb +38 -38
- data/test/unit/tc_examples_Arguments.rb +130 -130
- data/test/unit/tc_extras.rb +24 -24
- data/test/unit/tc_option_required.rb +38 -38
- data/test/unit/tc_option_value_aliases.rb +44 -44
- data/test/unit/tc_specifications.rb +7 -7
- data/test/unit/tc_typed_options.rb +200 -200
- data/test/unit/tc_usage.rb +69 -69
- data/test/unit/tc_with_action.rb +23 -23
- metadata +9 -8
data/test/unit/tc_usage.rb
CHANGED
@@ -10,122 +10,122 @@ require 'stringio'
|
|
10
10
|
|
11
11
|
class Test_Usage < Test::Unit::TestCase
|
12
12
|
|
13
|
-
|
13
|
+
def test_empty_default
|
14
14
|
|
15
|
-
|
15
|
+
specifications = []
|
16
16
|
|
17
|
-
|
17
|
+
stream = StringIO.new
|
18
18
|
|
19
|
-
|
19
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog'
|
20
20
|
|
21
|
-
|
21
|
+
expected = <<EOF_output
|
22
22
|
USAGE: myprog [ ... flags and options ... ]
|
23
23
|
|
24
24
|
EOF_output
|
25
|
-
|
25
|
+
actual = stream.string
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
assert_equal expected, actual
|
28
|
+
end
|
29
29
|
|
30
|
-
|
30
|
+
def test_empty_all
|
31
31
|
|
32
|
-
|
32
|
+
specifications = []
|
33
33
|
|
34
|
-
|
34
|
+
stream = StringIO.new
|
35
35
|
|
36
|
-
|
36
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: ''
|
37
37
|
|
38
|
-
|
38
|
+
expected = <<EOF_output
|
39
39
|
USAGE: myprog
|
40
40
|
|
41
41
|
EOF_output
|
42
|
-
|
42
|
+
actual = stream.string
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
assert_equal expected, actual
|
45
|
+
end
|
46
46
|
|
47
|
-
|
47
|
+
def test_empty_all_with_info_line_of_one_string
|
48
48
|
|
49
|
-
|
49
|
+
specifications = []
|
50
50
|
|
51
|
-
|
51
|
+
stream = StringIO.new
|
52
52
|
|
53
|
-
|
53
|
+
info = 'myprog version'.freeze
|
54
54
|
|
55
|
-
|
55
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info
|
56
56
|
|
57
|
-
|
57
|
+
expected = <<EOF_output
|
58
58
|
myprog version
|
59
59
|
USAGE: myprog
|
60
60
|
|
61
61
|
EOF_output
|
62
|
-
|
62
|
+
actual = stream.string
|
63
63
|
|
64
|
-
|
65
|
-
|
64
|
+
assert_equal expected, actual
|
65
|
+
end
|
66
66
|
|
67
|
-
|
67
|
+
def test_empty_all_with_info_lines
|
68
68
|
|
69
|
-
|
69
|
+
specifications = []
|
70
70
|
|
71
|
-
|
71
|
+
stream = StringIO.new
|
72
72
|
|
73
|
-
|
73
|
+
info_lines = [
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
'Synesis Software My Program',
|
76
|
+
'version 1',
|
77
|
+
].freeze
|
78
78
|
|
79
|
-
|
79
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info_lines
|
80
80
|
|
81
|
-
|
81
|
+
expected = <<EOF_output
|
82
82
|
Synesis Software My Program
|
83
83
|
version 1
|
84
84
|
USAGE: myprog
|
85
85
|
|
86
86
|
EOF_output
|
87
|
-
|
87
|
+
actual = stream.string
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
assert_equal expected, actual
|
90
|
+
end
|
91
91
|
|
92
|
-
|
92
|
+
def test_empty_all_with_info_lines_including_version
|
93
93
|
|
94
|
-
|
94
|
+
specifications = []
|
95
95
|
|
96
|
-
|
96
|
+
stream = StringIO.new
|
97
97
|
|
98
|
-
|
98
|
+
info_lines = [
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
'Synesis Software My Program',
|
101
|
+
:version
|
102
|
+
].freeze
|
103
103
|
|
104
|
-
|
104
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info_lines, version: [ 1, 0, 1], version_prefix: 'v'
|
105
105
|
|
106
|
-
|
106
|
+
expected = <<EOF_output
|
107
107
|
Synesis Software My Program
|
108
108
|
myprog v1.0.1
|
109
109
|
USAGE: myprog
|
110
110
|
|
111
111
|
EOF_output
|
112
|
-
|
112
|
+
actual = stream.string
|
113
113
|
|
114
|
-
|
115
|
-
|
114
|
+
assert_equal expected, actual
|
115
|
+
end
|
116
116
|
|
117
|
-
|
117
|
+
def test_one_alias_default
|
118
118
|
|
119
|
-
|
119
|
+
specifications = [
|
120
120
|
|
121
|
-
|
122
|
-
|
121
|
+
CLASP::Flag.Version
|
122
|
+
]
|
123
123
|
|
124
|
-
|
124
|
+
stream = StringIO.new
|
125
125
|
|
126
|
-
|
126
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog'
|
127
127
|
|
128
|
-
|
128
|
+
expected = <<EOF_output
|
129
129
|
USAGE: myprog [ ... flags and options ... ]
|
130
130
|
|
131
131
|
flags/options:
|
@@ -134,23 +134,23 @@ flags/options:
|
|
134
134
|
\t\t#{CLASP::Flag.Version.help}
|
135
135
|
|
136
136
|
EOF_output
|
137
|
-
|
137
|
+
actual = stream.string
|
138
138
|
|
139
|
-
|
140
|
-
|
139
|
+
assert_equal expected, actual
|
140
|
+
end
|
141
141
|
|
142
|
-
|
142
|
+
def test_one_alias_all
|
143
143
|
|
144
|
-
|
144
|
+
specifications = [
|
145
145
|
|
146
|
-
|
147
|
-
|
146
|
+
CLASP::Flag.Version
|
147
|
+
]
|
148
148
|
|
149
|
-
|
149
|
+
stream = StringIO.new
|
150
150
|
|
151
|
-
|
151
|
+
CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: ''
|
152
152
|
|
153
|
-
|
153
|
+
expected = <<EOF_output
|
154
154
|
USAGE: myprog
|
155
155
|
|
156
156
|
flags/options:
|
@@ -159,9 +159,9 @@ flags/options:
|
|
159
159
|
\t\t#{CLASP::Flag.Version.help}
|
160
160
|
|
161
161
|
EOF_output
|
162
|
-
|
162
|
+
actual = stream.string
|
163
163
|
|
164
|
-
|
165
|
-
|
164
|
+
assert_equal expected, actual
|
165
|
+
end
|
166
166
|
end
|
167
167
|
|
data/test/unit/tc_with_action.rb
CHANGED
@@ -10,40 +10,40 @@ require 'test/unit'
|
|
10
10
|
|
11
11
|
class Test_WithAction < Test::Unit::TestCase
|
12
12
|
|
13
|
-
|
13
|
+
def test_flag_with_action
|
14
14
|
|
15
|
-
|
15
|
+
debug = false
|
16
16
|
|
17
|
-
|
17
|
+
specifications = [
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
CLASP.Flag('--debug', alias: '-d') { debug = true }
|
20
|
+
]
|
21
|
+
argv = []
|
22
|
+
args = CLASP.parse argv, specifications
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
assert_equal 0, args.flags.size
|
25
|
+
assert_equal 0, args.options.size
|
26
|
+
assert_equal 0, args.values.size
|
27
27
|
|
28
|
-
|
28
|
+
assert_false debug
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
argv2 = [ '--debug' ]
|
31
|
+
args2 = CLASP.parse argv2, specifications
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
assert_equal 1, args2.flags.size
|
34
|
+
assert_equal 0, args2.options.size
|
35
|
+
assert_equal 0, args2.values.size
|
36
36
|
|
37
|
-
|
37
|
+
assert_false debug
|
38
38
|
|
39
|
-
|
39
|
+
if ix = args2.flags.index('--debug')
|
40
40
|
|
41
|
-
|
41
|
+
flag = args2.flags[ix]
|
42
42
|
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
assert_true debug
|
43
|
+
flag.argument_specification.action.call(flag, flag.argument_specification)
|
47
44
|
end
|
45
|
+
|
46
|
+
assert_true debug
|
47
|
+
end
|
48
48
|
end
|
49
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clasp-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xqsr3
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.39'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.39'
|
27
27
|
description: |
|
28
28
|
Command-Line Argument Sorting and Parsing library that provides a powerful abstraction of command-line interpretation facilities.
|
29
29
|
|
@@ -78,7 +78,7 @@ homepage: http://github.com/synesissoftware/CLASP.Ruby
|
|
78
78
|
licenses:
|
79
79
|
- BSD-3-Clause
|
80
80
|
metadata: {}
|
81
|
-
post_install_message:
|
81
|
+
post_install_message:
|
82
82
|
rdoc_options: []
|
83
83
|
require_paths:
|
84
84
|
- lib
|
@@ -96,8 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
|
100
|
-
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.7.6.3
|
101
|
+
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: CLASP.Ruby
|
103
104
|
test_files: []
|