clasp-ruby 0.18.1 → 0.18.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/examples/simple_command_line_no_specifications.rb +30 -0
- data/lib/clasp/arguments.rb +5 -6
- data/lib/clasp/doc_.rb +41 -24
- data/lib/clasp/version.rb +2 -2
- metadata +18 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0bfeb7de8319fee62e174f609591715f0910e1ad
|
4
|
+
data.tar.gz: cc60cc8e5ce0c2a841f024785cccc0d2c90a54ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e7ab5192e70f3b5dc243c81fc3d8a645fea11ae5cb64a7efed074460ec2339cac839b504917d6dc225a76899dcb726dd03078fa1bafd1b0251b4337521a3969
|
7
|
+
data.tar.gz: d502c1f31d0f13aad64e7e680288285d795ce5a0edb275a085be27c6bf0f2dc4b90c838425e6470a6d446f82721ac9fb818c1f8e8692ce9df7a60c52da987171
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
require 'clasp'
|
6
|
+
|
7
|
+
argv = %w{ --show-all=true infile -c outfile }
|
8
|
+
|
9
|
+
args = CLASP::Arguments.new(argv)
|
10
|
+
|
11
|
+
puts args.flags.size # => 1
|
12
|
+
puts args.flags[0] # => -c
|
13
|
+
puts args.flags[0].name # => -c
|
14
|
+
puts args.flags[0].inspect # => #<CLASP::Arguments::FlagArgument:0x007f87e18d4530 @arg="-c", @given_index=2, @given_name="-c", @argument_alias=nil, @given_hyphens=1, @given_label="c", @name="-c", @extras={}>
|
15
|
+
|
16
|
+
puts args.options.size # => 1
|
17
|
+
puts args.options[0] # => --show-all=true
|
18
|
+
puts args.options[0].name # => --show-all
|
19
|
+
puts args.options[0].value # => true
|
20
|
+
puts args.options[0].inspect # => #<CLASP::Arguments::OptionArgument:0x007f87e18d4940 @arg="--show-all=true", @given_index=0, @given_name="--show-all", @argument_alias=nil, @given_hyphens=2, @given_label="show-all", @value="true", @name="--show-all", @extras={}>
|
21
|
+
|
22
|
+
puts args.values.size # => 2
|
23
|
+
puts args.values[0] # => infile
|
24
|
+
puts args.values[0].given_index # => 1
|
25
|
+
puts args.values[1] # => outfile
|
26
|
+
puts args.values[1].given_index # => 3
|
27
|
+
|
28
|
+
# ############################## end of file ############################# #
|
29
|
+
|
30
|
+
|
data/lib/clasp/arguments.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# CLASP.Ruby
|
7
7
|
#
|
8
8
|
# Created: 14th February 2014
|
9
|
-
# Updated:
|
9
|
+
# Updated: 12th April 2019
|
10
10
|
#
|
11
11
|
# Home: http://github.com/synesissoftware/CLASP.Ruby
|
12
12
|
#
|
@@ -341,6 +341,7 @@ class Arguments
|
|
341
341
|
@argv_original_copy = argv.dup.freeze
|
342
342
|
|
343
343
|
@specifications = specifications
|
344
|
+
@aliases = @specifications
|
344
345
|
|
345
346
|
specifications = nil if specifications and specifications.empty?
|
346
347
|
|
@@ -548,7 +549,7 @@ class Arguments
|
|
548
549
|
attr_reader :specifications
|
549
550
|
|
550
551
|
# [DEPRECATED] Instead refer to +specifications+
|
551
|
-
|
552
|
+
attr_reader :aliases
|
552
553
|
|
553
554
|
# an immutable array of flags
|
554
555
|
attr_reader :flags
|
@@ -598,8 +599,7 @@ class Arguments
|
|
598
599
|
# === Signature
|
599
600
|
#
|
600
601
|
# * *Parameters*:
|
601
|
-
# - +id+:: (String, CLASP::Flag) The name of a flag, or the flag
|
602
|
-
# itself
|
602
|
+
# - +id+:: (String, CLASP::Flag) The name of a flag, or the flag itself
|
603
603
|
def find_flag(id)
|
604
604
|
|
605
605
|
flags.each do |flag|
|
@@ -616,8 +616,7 @@ class Arguments
|
|
616
616
|
# === Signature
|
617
617
|
#
|
618
618
|
# * *Parameters*:
|
619
|
-
# - +id+:: (String, CLASP::Flag) The name of a option, or the option
|
620
|
-
# itself
|
619
|
+
# - +id+:: (String, CLASP::Flag) The name of a option, or the option itself
|
621
620
|
def find_option(id)
|
622
621
|
|
623
622
|
options.each do |option|
|
data/lib/clasp/doc_.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Documentation of the CLASP.Ruby modules
|
6
6
|
#
|
7
7
|
# Created: 11th June 2016
|
8
|
-
# Updated:
|
8
|
+
# Updated: 12th April 2019
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
@@ -57,14 +57,23 @@
|
|
57
57
|
#
|
58
58
|
# args = CLASP::Arguments.new(argv)
|
59
59
|
#
|
60
|
-
# puts args.flags.size
|
61
|
-
# puts args.flags[0]
|
62
|
-
# puts args.
|
63
|
-
# puts args.
|
64
|
-
#
|
65
|
-
# puts args.
|
66
|
-
# puts args.
|
67
|
-
# puts args.
|
60
|
+
# puts args.flags.size # => 1
|
61
|
+
# puts args.flags[0] # => -c
|
62
|
+
# puts args.flags[0].name # => -c
|
63
|
+
# puts args.flags[0].inspect # => #<CLASP::Arguments::FlagArgument:0x007f87e18d4530 @arg="-c", @given_index=2, @given_name="-c", @argument_alias=nil, @given_hyphens=1, @given_label="c", @name="-c", @extras={}>
|
64
|
+
#
|
65
|
+
# puts args.options.size # => 1
|
66
|
+
# puts args.options[0] # => --show-all=true
|
67
|
+
# puts args.options[0].name # => --show-all
|
68
|
+
# puts args.options[0].value # => true
|
69
|
+
# puts args.options[0].inspect # => #<CLASP::Arguments::OptionArgument:0x007f87e18d4940 @arg="--show-all=true", @given_index=0, @given_name="--show-all", @argument_alias=nil, @given_hyphens=2, @given_label="show-all", @value="true", @name="--show-all", @extras={}>
|
70
|
+
#
|
71
|
+
# puts args.values.size # => 2
|
72
|
+
# puts args.values[0] # => infile
|
73
|
+
# puts args.values[0].given_index # => 1
|
74
|
+
# puts args.values[1] # => outfile
|
75
|
+
# puts args.values[1].given_index # => 3
|
76
|
+
#
|
68
77
|
#
|
69
78
|
# ==== Use of the special double-slash flag to treat all subsequent arguments as values
|
70
79
|
#
|
@@ -72,13 +81,16 @@
|
|
72
81
|
#
|
73
82
|
# args = CLASP::Arguments.new(argv)
|
74
83
|
#
|
75
|
-
# puts args.flags.size
|
76
|
-
#
|
77
|
-
# puts args.options
|
78
|
-
# puts args.
|
79
|
-
# puts args.
|
80
|
-
#
|
81
|
-
# puts args.values
|
84
|
+
# puts args.flags.size # => 0
|
85
|
+
#
|
86
|
+
# puts args.options.size # => 1
|
87
|
+
# puts args.options[0] # => --show-all
|
88
|
+
# puts args.options[0].inspect # => #<CLASP::Arguments::OptionArgument:0x007fd23aa3aca0 @arg="--show-all=true", @given_index=0, @given_name="--show-all", @argument_alias=nil, @given_hyphens=2, @given_label="show-all", @value="true", @name="--show-all", @extras={}>
|
89
|
+
#
|
90
|
+
# puts args.values.size # => 3
|
91
|
+
# puts args.values[0] # => infile
|
92
|
+
# puts args.values[1] # => outfile
|
93
|
+
# puts args.values[2] # => "-c"
|
82
94
|
#
|
83
95
|
# ==== Use of flag short forms
|
84
96
|
#
|
@@ -93,8 +105,8 @@
|
|
93
105
|
# args = CLASP::Arguments.new(argv, specifications)
|
94
106
|
#
|
95
107
|
# puts args.flags.size # => 2
|
96
|
-
# puts args.flags[0].name # =>
|
97
|
-
# puts args.flags[1].name # =>
|
108
|
+
# puts args.flags[0].name # => --trace-output
|
109
|
+
# puts args.flags[1].name # => --verbose
|
98
110
|
# puts args.options.size # => 0
|
99
111
|
# puts args.values.size # => 0
|
100
112
|
#
|
@@ -127,17 +139,21 @@
|
|
127
139
|
# args = CLASP::Arguments.new(argv, specifications)
|
128
140
|
#
|
129
141
|
# puts args.flags.size # => 1
|
130
|
-
# puts args.flags[0] # =>
|
142
|
+
# puts args.flags[0] # => -c
|
143
|
+
# puts args.flags[0].inspect # => #<CLASP::Arguments::FlagArgument:0x007f8593b0ddd8 @arg="-c", @given_index=0, @given_name="-c", @argument_alias=nil, @given_hyphens=1, @given_label="c", @name="-c", @extras={}>
|
144
|
+
#
|
131
145
|
# puts args.options.size # => 1
|
132
|
-
# puts args.options[0] # =>
|
146
|
+
# puts args.options[0] # => --show-all
|
147
|
+
# puts args.options[0].inspect # => "#<CLASP::Arguments::OptionArgument:0x007f8593b0db80 @arg="-a", @given_index=1, @given_name="-a", @argument_alias=#<CLASP::OptionArgument:0x007f8593b2ea10 @name="--show-all", @aliases=["-a"], @help=nil, @values_range=[], @default_value=nil, @extras={}>, @given_hyphens=1, @given_label="a", @value="true", @name="--show-all", @extras={}>"
|
148
|
+
#
|
133
149
|
# puts args.values.size # => 2
|
134
|
-
# puts args.values[0] # =>
|
135
|
-
# puts args.values[1] # =>
|
150
|
+
# puts args.values[0] # => infile
|
151
|
+
# puts args.values[1] # => outfile
|
136
152
|
#
|
137
153
|
# === Classes of interest
|
138
154
|
# * ::CLASP::Arguments
|
139
|
-
# * ::CLASP::FlagArgument
|
140
|
-
# * ::CLASP::OptionArgument
|
155
|
+
# * ::CLASP::Arguments::FlagArgument
|
156
|
+
# * ::CLASP::Arguments::OptionArgument
|
141
157
|
#
|
142
158
|
# === Functions of interest
|
143
159
|
# * ::CLASP.show_version()
|
@@ -149,3 +165,4 @@ end # module CLASP
|
|
149
165
|
|
150
166
|
# ############################## end of file ############################# #
|
151
167
|
|
168
|
+
|
data/lib/clasp/version.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Version for CLASP.Ruby library
|
6
6
|
#
|
7
7
|
# Created: 16th November 2014
|
8
|
-
# Updated:
|
8
|
+
# Updated: 12th April 2019
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/CLASP.Ruby
|
11
11
|
#
|
@@ -51,7 +51,7 @@
|
|
51
51
|
module CLASP
|
52
52
|
|
53
53
|
# Current version of the CLASP.Ruby library
|
54
|
-
VERSION = '0.18.
|
54
|
+
VERSION = '0.18.2'
|
55
55
|
|
56
56
|
private
|
57
57
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
metadata
CHANGED
@@ -1,52 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clasp-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
5
|
-
prerelease:
|
4
|
+
version: 0.18.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Wilson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: xqsr3
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.30'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.30'
|
30
|
-
description:
|
31
|
-
powerful
|
32
|
-
|
33
|
-
abstraction of command-line interpretation facilities. CLASP.Ruby is a Ruby port
|
34
|
-
of the popular CLASP (C/C++) library, and provides declarative specification of
|
35
|
-
command-line flags and options, aliasing, flag combination, UNIX de-facto standard
|
36
|
-
flag processing, and a number of utility functions for expressing usage and version
|
37
|
-
information.
|
38
|
-
|
39
|
-
'
|
27
|
+
description: |
|
28
|
+
Command-Line Argument Sorting and Parsing library that provides a powerful
|
29
|
+
abstraction of command-line interpretation facilities. CLASP.Ruby is a Ruby port of the popular CLASP (C/C++) library, and provides declarative specification of command-line flags and options, aliasing, flag combination, UNIX de-facto standard flag processing, and a number of utility functions for expressing usage and version information.
|
40
30
|
email: matthew@synesis.com.au
|
41
31
|
executables: []
|
42
32
|
extensions: []
|
43
33
|
extra_rdoc_files: []
|
44
34
|
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
45
37
|
- examples/cr-example.rb
|
46
38
|
- examples/flag_and_option_specifications.md
|
47
39
|
- examples/flag_and_option_specifications.rb
|
48
40
|
- examples/show_usage_and_version.md
|
49
41
|
- examples/show_usage_and_version.rb
|
42
|
+
- examples/simple_command_line_no_specifications.rb
|
43
|
+
- lib/clasp-ruby.rb
|
44
|
+
- lib/clasp.rb
|
50
45
|
- lib/clasp/arguments.rb
|
51
46
|
- lib/clasp/clasp.rb
|
52
47
|
- lib/clasp/cli.rb
|
@@ -54,18 +49,16 @@ files:
|
|
54
49
|
- lib/clasp/old_module.rb
|
55
50
|
- lib/clasp/specifications.rb
|
56
51
|
- lib/clasp/version.rb
|
57
|
-
- lib/clasp-ruby.rb
|
58
|
-
- lib/clasp.rb
|
59
52
|
- test/scratch/test_list_command_line.rb
|
60
53
|
- test/scratch/test_specifications.rb
|
61
54
|
- test/scratch/test_usage.rb
|
62
55
|
- test/scratch/test_usage_from_DATA.rb
|
63
56
|
- test/scratch/test_usage_with_duplicate_specifications.rb
|
57
|
+
- test/unit/tc_ARGV_rewrite.rb
|
64
58
|
- test/unit/tc_arguments_1.rb
|
65
59
|
- test/unit/tc_arguments_2.rb
|
66
60
|
- test/unit/tc_arguments_3.rb
|
67
61
|
- test/unit/tc_arguments_inspect.rb
|
68
|
-
- test/unit/tc_ARGV_rewrite.rb
|
69
62
|
- test/unit/tc_cli.rb
|
70
63
|
- test/unit/tc_defaults_1.rb
|
71
64
|
- test/unit/tc_examples_Arguments.rb
|
@@ -74,31 +67,28 @@ files:
|
|
74
67
|
- test/unit/tc_specifications.rb
|
75
68
|
- test/unit/tc_usage.rb
|
76
69
|
- test/unit/ts_all.rb
|
77
|
-
- README.md
|
78
|
-
- LICENSE
|
79
70
|
homepage: http://github.com/synesissoftware/CLASP.Ruby
|
80
71
|
licenses:
|
81
72
|
- BSD-3-Clause
|
73
|
+
metadata: {}
|
82
74
|
post_install_message:
|
83
75
|
rdoc_options: []
|
84
76
|
require_paths:
|
85
77
|
- lib
|
86
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
79
|
requirements:
|
89
|
-
- -
|
80
|
+
- - ">="
|
90
81
|
- !ruby/object:Gem::Version
|
91
82
|
version: 1.9.3
|
92
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
84
|
requirements:
|
95
|
-
- -
|
85
|
+
- - ">="
|
96
86
|
- !ruby/object:Gem::Version
|
97
87
|
version: '0'
|
98
88
|
requirements: []
|
99
89
|
rubyforge_project:
|
100
|
-
rubygems_version:
|
90
|
+
rubygems_version: 2.6.11
|
101
91
|
signing_key:
|
102
|
-
specification_version:
|
92
|
+
specification_version: 4
|
103
93
|
summary: CLASP.Ruby
|
104
94
|
test_files: []
|