yaggo 1.5.10
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 +7 -0
- data/README.md +107 -0
- data/bin/create_yaggo_one_file +45 -0
- data/bin/yaggo +22 -0
- data/lib/yaggo/dsl.rb +573 -0
- data/lib/yaggo/general.rb +127 -0
- data/lib/yaggo/library.rb +209 -0
- data/lib/yaggo/main.rb +152 -0
- data/lib/yaggo/man_page.rb +449 -0
- data/lib/yaggo/parser.rb +404 -0
- data/lib/yaggo/stub.rb +42 -0
- data/lib/yaggo/version.rb +1 -0
- data/lib/yaggo/zsh_completion.rb +94 -0
- metadata +58 -0
data/lib/yaggo/stub.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# This file is part of Yaggo.
|
2
|
+
|
3
|
+
# Yaggo is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
|
8
|
+
# Yaggo is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with Yaggo. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
|
17
|
+
def display_stub_yaggo_file file
|
18
|
+
stub = <<EOS
|
19
|
+
# Stub file generated by yaggo. Modify to your liking
|
20
|
+
purpose = "Foo software to do bar and baz, one line description"
|
21
|
+
description = "A longer multiline description of how Foo does bar and baz
|
22
|
+
|
23
|
+
Really, it works great, you should try all the options below
|
24
|
+
"
|
25
|
+
|
26
|
+
option("b", "bar") {
|
27
|
+
description "Insist on bar"
|
28
|
+
flag }
|
29
|
+
option("z", "baz") {
|
30
|
+
description "Baz parameter"
|
31
|
+
int64; default "5" }
|
32
|
+
option("l", "long") {
|
33
|
+
description "Long switch can be used multiple time"
|
34
|
+
int32; multiple }
|
35
|
+
arg("OneArg") {
|
36
|
+
description "first arg"
|
37
|
+
string }
|
38
|
+
EOS
|
39
|
+
|
40
|
+
out = file ? open(file, "W") : STDOUT
|
41
|
+
out.write(stub)
|
42
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$yaggo_version = "1.5.10"
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# This file is part of Yaggo.
|
2
|
+
|
3
|
+
# Yaggo is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
|
8
|
+
# Yaggo is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with Yaggo. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
|
17
|
+
def zsh_conflict_option o
|
18
|
+
conflict_options = o.conflict + $options.map { |co|
|
19
|
+
(co.conflict.include?(o.short) || co.conflict.include?(o.long)) ? (co.short || co.long) : nil
|
20
|
+
}.compact.uniq
|
21
|
+
return "" if conflict_options.empty?
|
22
|
+
"'(" + conflict_options.map { |co_name|
|
23
|
+
co = $opt_hash[co_name]
|
24
|
+
[co.short && "-#{co.short}", co.long && "--#{co.long}"]
|
25
|
+
}.flatten.compact.uniq.join(" ") + ")'"
|
26
|
+
end
|
27
|
+
|
28
|
+
def zsh_switches_option o
|
29
|
+
switches = if o.type == :flag
|
30
|
+
[o.short && "-#{o.short}", o.long && "--#{o.long}"]
|
31
|
+
else
|
32
|
+
[o.short && "-#{o.short}+", o.long && "--#{o.long}="]
|
33
|
+
end
|
34
|
+
switches.compact!
|
35
|
+
swstr = switches.size > 1 ? "{#{switches.join(",")}}" : switches[0]
|
36
|
+
swstr = "\\*#{swstr}" if o.multiple
|
37
|
+
swstr
|
38
|
+
end
|
39
|
+
|
40
|
+
def zsh_type_completion o, with_type = true
|
41
|
+
typedescr = o.typestr || o.type.id2name
|
42
|
+
typename = with_type ? ":" + typedescr : ""
|
43
|
+
guard_help = "#{typedescr} #{o.description || ""}"
|
44
|
+
case o.type
|
45
|
+
when :flag
|
46
|
+
return ""
|
47
|
+
when :enum
|
48
|
+
return "#{typename}:(#{o.enum.join(" ")})"
|
49
|
+
when :string, :c_string
|
50
|
+
case o.typestr || ""
|
51
|
+
when /file|path/i
|
52
|
+
return "#{typename}:_files"
|
53
|
+
when /dir/i
|
54
|
+
return "#{typename}:_files -/"
|
55
|
+
else
|
56
|
+
return typename
|
57
|
+
end
|
58
|
+
when :int32, :int64, :int, :long
|
59
|
+
suffixes = o.suffix ? "[kMGTPE]" : ""
|
60
|
+
return "#{typename}:_guard \"[0-9+-]##{suffixes}\" \"#{guard_help}\""
|
61
|
+
when :uint32, :uint64
|
62
|
+
suffixes = o.suffix ? "[kMGTPE]" : ""
|
63
|
+
return "#{typename}:_guard \"[0-9+]##{suffixes}\" \"#{guard_help}\""
|
64
|
+
when :double
|
65
|
+
suffixes = "[munpfakMGTPE]" if o.suffix
|
66
|
+
return "#{typename}:_guard \"[0-9.eE+-]##{suffixes}\" \"#{guard_help}\""
|
67
|
+
else
|
68
|
+
return default
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def output_zsh_completion(fd, filename)
|
73
|
+
cmdname = File.basename(filename).gsub(/^_/, "")
|
74
|
+
|
75
|
+
fd.puts("#compdef #{cmdname}", "",
|
76
|
+
"local context state state_descr line",
|
77
|
+
"typeset -A opt_args", "")
|
78
|
+
return if $options.empty? && $args.empty?
|
79
|
+
fd.puts("_arguments -s -S \\")
|
80
|
+
$options.each { |o|
|
81
|
+
conflicts = zsh_conflict_option o
|
82
|
+
switches = zsh_switches_option o
|
83
|
+
descr = o.description ? "[#{o.description}]" : ""
|
84
|
+
action = zsh_type_completion o, true
|
85
|
+
fd.puts("#{conflicts}#{switches}'#{descr}#{action}' \\")
|
86
|
+
}
|
87
|
+
$args.each { |a|
|
88
|
+
descr = a.description || " "
|
89
|
+
action = zsh_type_completion a, false
|
90
|
+
many = a.multiple ? "*" : ""
|
91
|
+
fd.puts("'#{many}:#{descr}#{action}' \\")
|
92
|
+
}
|
93
|
+
fd.puts(" && return 0")
|
94
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yaggo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.5.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guillaume Marçais
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Yaggo defines a DSL to generate GNU compatible command line parsers for
|
14
|
+
C++ using getopt.
|
15
|
+
email:
|
16
|
+
- gmarcais@umd.edu
|
17
|
+
executables:
|
18
|
+
- yaggo
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- README.md
|
23
|
+
- bin/create_yaggo_one_file
|
24
|
+
- bin/yaggo
|
25
|
+
- lib/yaggo/dsl.rb
|
26
|
+
- lib/yaggo/general.rb
|
27
|
+
- lib/yaggo/library.rb
|
28
|
+
- lib/yaggo/main.rb
|
29
|
+
- lib/yaggo/man_page.rb
|
30
|
+
- lib/yaggo/parser.rb
|
31
|
+
- lib/yaggo/stub.rb
|
32
|
+
- lib/yaggo/version.rb
|
33
|
+
- lib/yaggo/zsh_completion.rb
|
34
|
+
homepage: https://github.com/gmarcais/yaggo
|
35
|
+
licenses:
|
36
|
+
- GPL-3.0
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 1.3.6
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.6.11
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Yet Another Generator for getopt
|
58
|
+
test_files: []
|