l43_xargs 0.1.0 → 0.1.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/lib/l43/xargs/forwarder.rb +42 -0
- data/lib/l43/xargs/open_struct.rb +3 -1
- data/lib/l43/xargs/version.rb +1 -1
- data/lib/l43/xargs.rb +9 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37bb58827f148aba9c53fabe6b29ae7d0afb7b702999648ce2bc86fb618c83ba
|
|
4
|
+
data.tar.gz: 9639a86b754956cbd686fbf5610016698b6a2037e1f2b8f17c0f376760e18442
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df5ff18d8604c824844d5485433c9a720f0bfa19c76a5dc901b0bc9475e34cdc2ddc2e6d08bf342b3a9a7c142dbe1846176d93a68f5ca955b17959c88d4c1f79
|
|
7
|
+
data.tar.gz: 116c6b060e272737b05d753c8ba5a244ade111bba263e1786fba0bf40a2793cbb2a4e5d478f379a2abb79b2a8d652b50b0176d157a36efed18429eb55a2461f6
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module L43
|
|
4
|
+
class Xargs
|
|
5
|
+
class Forwarder
|
|
6
|
+
|
|
7
|
+
def forward!
|
|
8
|
+
args.each do |arg|
|
|
9
|
+
_forward_arg(arg)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
attr_reader :args, :kwds, :is_private, :subject
|
|
15
|
+
|
|
16
|
+
def initialize(*args, subject:, kwds:, private: true)
|
|
17
|
+
@args = args
|
|
18
|
+
@kwds = kwds
|
|
19
|
+
@subject = subject
|
|
20
|
+
@is_private = private
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def _forward_arg(arg)
|
|
24
|
+
value = kwds[arg].value
|
|
25
|
+
if is_private
|
|
26
|
+
_sing_class.module_eval do
|
|
27
|
+
private
|
|
28
|
+
define_method(arg) { value }
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
subject.define_singleton_method(arg) {value}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def _sing_class
|
|
36
|
+
class << subject; self; end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
data/lib/l43/xargs/version.rb
CHANGED
data/lib/l43/xargs.rb
CHANGED
|
@@ -13,6 +13,7 @@ require_relative 'xargs/deconstruct'
|
|
|
13
13
|
require_relative 'xargs/defined_args'
|
|
14
14
|
require_relative 'xargs/anon_flag'
|
|
15
15
|
require_relative 'xargs/anon_keyword'
|
|
16
|
+
require_relative 'xargs/forwarder'
|
|
16
17
|
require_relative 'xargs/parse'
|
|
17
18
|
|
|
18
19
|
module L43
|
|
@@ -75,6 +76,14 @@ module L43
|
|
|
75
76
|
defined_args.help_description(indent:, newline:, program_name:, sections:, section_colors:, usage:)
|
|
76
77
|
end
|
|
77
78
|
|
|
79
|
+
def forward_to_kwds!(subject, *args, private: true, without: [])
|
|
80
|
+
raise IllegalMonitorState, "must not call forward_to_kwds! before calling parse" unless @__full_result__
|
|
81
|
+
args = full_result.kwds.keys if args.empty?
|
|
82
|
+
args -= Array(without)
|
|
83
|
+
Forwarder.new(*args, subject:, kwds: full_result.kwds, private:).forward!
|
|
84
|
+
self
|
|
85
|
+
end
|
|
86
|
+
|
|
78
87
|
def full_result
|
|
79
88
|
raise IllegalMonitorState, "must not call full_result before calling parse" unless @__full_result__
|
|
80
89
|
@__full_result__
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: l43_xargs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Dober
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- lib/l43/xargs/defined_args.rb
|
|
69
69
|
- lib/l43/xargs/descriptions.rb
|
|
70
70
|
- lib/l43/xargs/flag.rb
|
|
71
|
+
- lib/l43/xargs/forwarder.rb
|
|
71
72
|
- lib/l43/xargs/keyword.rb
|
|
72
73
|
- lib/l43/xargs/open_struct.rb
|
|
73
74
|
- lib/l43/xargs/output.rb
|