shellopts 2.0.16 → 2.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 256d4f5a28f8f4028030ac17631d4e93a36584b77c96cd8090ecab8dc393f36f
4
- data.tar.gz: 381c0515800feb0a4d2327d336ed35c43e5441915cf6aef5cb4ebd365cbe8d39
3
+ metadata.gz: ebd7911e579af4ddddd064399e7b456b45cef80dc3c6589e404ba5e32811bd6c
4
+ data.tar.gz: ea555ad68d0d6c43bad39a4e195e6661f72e1e43b6d3dbe647f4c8ff13d7eea3
5
5
  SHA512:
6
- metadata.gz: ac3af229c984160970034b5bbef21584bb5d78e6581f3efb2d4d9c10e9217ebde1e3cc248136224c4859d9a73ded08fc1a6782ebddb55a2d8eff1b5d480c42f9
7
- data.tar.gz: 855d30fcd66f441a09ab53d50284a11e2a24bcd8c24b9c5573e1783c571005ab6b7a383aefbd0d9883893207550fe9bd880def44e361f000c87289a3476fe48f
6
+ metadata.gz: 453d3bd1e4354a56947623232f1fabcdc8d212a91d317ce16026c356c71c77ab53031e4e42d05242d0c04ce309ccd69fd75386d3d40705feac461f58d6a2c86b
7
+ data.tar.gz: 282655ab16154e1b50c25b6ddf8a07196a296f8a2bad4086cd78b8962a9003c22e1fb8dfbe2e339fc97973fef95b1cf9965a829bab23b2ad98f63df1aef8c009
data/PROBLEMS ADDED
@@ -0,0 +1,41 @@
1
+
2
+ # Subcommand options are not recognized unless there exists an option on the
3
+ # program level (try to remove -a below)
4
+
5
+ SPEC = %(
6
+ Foreign data wrapper maintenance tool
7
+
8
+ -a,an-option
9
+ Gryf
10
+
11
+ list.servers! -- DATABASE
12
+ List foreign servers
13
+
14
+ create.server! -- DATABASE FDW-SERVER MSSQL-DATABASE [MSSQL-HOST [MSSQL-PORT]]
15
+ Create a new FDW server
16
+
17
+ -c,credentials=EFILE
18
+ Credentials file. The credentials file is a YAML formatted file that can
19
+ define the fields 'user', 'password', 'host', and 'port'
20
+
21
+ drop.server! -- DATABASE FDW-SERVER
22
+ Drop a FDW server. This cascades to FDW users too
23
+
24
+ list.users! -- DATABASE
25
+ List FDW users. 'users' in this context is postgres users that have an
26
+ associated FDW user mapping
27
+
28
+ --servers @ Also list the user's FDW servers
29
+
30
+ create.user! -- DATABASE FDW-SERVER [FDW-USER [FDW-PASSWORD]]
31
+ Create a FDW user. The user has to exist beforehand, this command only adds
32
+ a user mapping to the user and grants the usage privilege
33
+
34
+ -c,credentials=EFILE
35
+ Credentials file
36
+
37
+ drop.user! -- DATABASE FDW-USER
38
+ Drops a FDW user. The postgres user is not dropped but the user's user
39
+ mapping and grants are
40
+ )
41
+
data/lib/ext/follow.rb ADDED
@@ -0,0 +1,26 @@
1
+
2
+ module Algorithm
3
+ class FollowEnumerator < Enumerator
4
+ def initialize(object, method = nil, &block)
5
+ closure = method ? lambda { |object| object.__send__(method) } : block
6
+ super() { |yielder|
7
+ while object
8
+ yielder << object
9
+ object = closure.call(object)
10
+ end
11
+ }
12
+ end
13
+ end
14
+
15
+ def follow(object, method = nil, &block)
16
+ !method.nil? || block_given? or raise ArgumentError, "Needs either a method or a block"
17
+ method.nil? == block_given? or raise ArgumentError, "Can't use both method and block"
18
+ FollowEnumerator.new(object, method, &block)
19
+ end
20
+
21
+ module_function :follow
22
+ end
23
+
24
+
25
+
26
+
@@ -52,7 +52,7 @@ module ShellOpts
52
52
  # These methods can be overridden by an option or a command (this constant
53
53
  # is not used - it is just for informational purposes)
54
54
  OVERRIDEABLE_METHOD_NAMES = %w(
55
- subcommand subcommand! supercommand!
55
+ subcommand subcommand! subcommands subcommands! supercommand!
56
56
  )
57
57
 
58
58
  # Redefine ::new to call #__initialize__
@@ -133,6 +133,13 @@ module ShellOpts
133
133
  #
134
134
  def subcommand!() __subcommand__! end
135
135
 
136
+ # Returns the concatenated identifier of subcommands (eg. :cmd.subcmd!)
137
+ def subcommands() __subcommands__ end
138
+
139
+ # Returns the subcommands in an array. This doesn't include the top-level
140
+ # program object
141
+ def subcommands!() __subcommands__! end
142
+
136
143
  # The parent command or nil. Initialized by #add_command
137
144
  #
138
145
  # Note: Can be overridden by a subcommand declaration (but not an
@@ -180,6 +187,16 @@ module ShellOpts
180
187
  # The actual subcommand object or nil if not present
181
188
  def __subcommand__!() @__subcommand__ end
182
189
 
190
+ # Implementation of the #subcommands method
191
+ def __subcommands__()
192
+ __subcommands__!.last&.__uid__&.to_sym
193
+ end
194
+
195
+ # Implementation of the #subcommands! method
196
+ def __subcommands__!()
197
+ ::Algorithm.follow(self.__subcommand__!, :__subcommand__!).to_a
198
+ end
199
+
183
200
  private
184
201
  def __initialize__(grammar)
185
202
  @__grammar__ = grammar
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.0.16"
2
+ VERSION = "2.0.17"
3
3
  end
data/lib/shellopts.rb CHANGED
@@ -5,6 +5,7 @@ require 'constrain'
5
5
  include Constrain
6
6
 
7
7
  require 'ext/array.rb'
8
+ require 'ext/follow.rb'
8
9
  require 'ext/forward_to.rb'
9
10
  require 'ext/lcs.rb'
10
11
  include ForwardTo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellopts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.16
4
+ version: 2.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-11 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forward_to
@@ -135,6 +135,7 @@ files:
135
135
  - ".rspec"
136
136
  - ".ruby-version"
137
137
  - Gemfile
138
+ - PROBLEMS
138
139
  - README.md
139
140
  - Rakefile
140
141
  - TODO
@@ -147,6 +148,7 @@ files:
147
148
  - doc/syntax.rb
148
149
  - doc/syntax.txt
149
150
  - lib/ext/array.rb
151
+ - lib/ext/follow.rb
150
152
  - lib/ext/forward_to.rb
151
153
  - lib/ext/lcs.rb
152
154
  - lib/shellopts.rb