fylla 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/Rakefile +12 -6
- data/bin/console +3 -3
- data/exe/fylla +1 -1
- data/fylla.gemspec +23 -22
- data/lib/fylla/completion_extension.rb +2 -1
- data/lib/fylla/completion_generator.rb +17 -15
- data/lib/fylla/parsed_option.rb +17 -15
- data/lib/fylla/thor/extensions/comma_array_extension.rb +4 -3
- data/lib/fylla/version.rb +1 -1
- data/lib/fylla.rb +7 -7
- metadata +50 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a3cc1382f79579d5a8130fbca473d8d056b6b212ed8c8e7968018ec65b7bfe
|
4
|
+
data.tar.gz: a4450072bcfd5092e69b1fe5c655c31cdd6cab163179dcc024baa855bee43494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fceea452d546e94729260a6bfd843acd6765214241d1ab2722955b3c6ede8f4a2976041083142dfc54deda0d82da49c38ae14771cd5238a3dd3131ad761b2a84
|
7
|
+
data.tar.gz: 6583452e70354478fd75377855302a78b9147e926cd6b8a6f39e0bcac7747c4cd79c73ddffa8916dbb7d332147d6cf645e03cd012723f3d47ecfa435ed352d0f
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
3
5
|
|
4
6
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
10
|
end
|
9
11
|
|
10
|
-
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fylla"
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require 'fylla'
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require "irb"
|
14
14
|
IRB.start(__FILE__)
|
data/exe/fylla
CHANGED
data/fylla.gemspec
CHANGED
@@ -1,21 +1,20 @@
|
|
1
|
-
lib = File.expand_path(
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require "fylla/version"
|
4
4
|
|
5
|
-
# rubocop:disable BlockLength
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = "fylla"
|
8
7
|
spec.version = Fylla::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ["Tyler Thrailkill"]
|
9
|
+
spec.email = ["tyler.b.thrailkill@gmail.com"]
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = "Adds functions for generating autocomplete scripts for Thor applications"
|
12
|
+
spec.description = "Fylla generates zsh and bash autocomplete scripts for Thor CLI applications."
|
13
|
+
spec.homepage = "https://github.com/snowe2010/fylla"
|
14
|
+
spec.license = "MIT"
|
16
15
|
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
16
|
+
spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs.
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/snowe2010/fylla/blob/master/CHANGELOG.md"
|
19
18
|
|
20
19
|
# Specify which files should be added to the gem when it is released.
|
21
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -25,15 +24,17 @@ Gem::Specification.new do |spec|
|
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
spec.bindir =
|
29
|
-
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f)}
|
30
|
-
spec.require_paths = [
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
31
30
|
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.
|
31
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
32
|
+
spec.add_development_dependency "codecov", "~> 0.1.14"
|
33
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
+
spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 13"
|
36
|
+
spec.add_development_dependency "rubocop", "~> 1.21"
|
37
|
+
spec.add_development_dependency "rubocop-minitest", "~> 0.27.0"
|
38
|
+
spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
|
39
|
+
spec.add_dependency "thor", ">= 0.19.0"
|
38
40
|
end
|
39
|
-
# rubocop:enable BlockLength
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "thor"
|
2
2
|
|
3
3
|
# add more options to Thor::Option
|
4
4
|
#
|
@@ -8,6 +8,7 @@ module Fylla
|
|
8
8
|
module Thor
|
9
9
|
module Option
|
10
10
|
attr_accessor :completion, :filter
|
11
|
+
|
11
12
|
def initialize(name, options = {})
|
12
13
|
@completion = options[:fylla]&.[](:completion)
|
13
14
|
@filter = options[:fylla]&.[](:filter)
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require
|
1
|
+
require_relative "parsed_option"
|
2
|
+
require_relative "parsed_command"
|
3
|
+
require_relative "parsed_subcommand"
|
4
|
+
require "erb"
|
5
5
|
|
6
6
|
module Fylla
|
7
7
|
module Thor
|
@@ -29,7 +29,7 @@ module Fylla
|
|
29
29
|
builder = map_to_completion_string [command]
|
30
30
|
completion = "#compdef _#{executable_name} #{executable_name}\n"
|
31
31
|
completion += builder
|
32
|
-
completion += %
|
32
|
+
completion += %(_#{executable_name} "$@")
|
33
33
|
completion
|
34
34
|
end
|
35
35
|
|
@@ -44,7 +44,7 @@ module Fylla
|
|
44
44
|
command = create_command_map all_commands, subcommand_classes
|
45
45
|
|
46
46
|
builder = map_to_completion_string [command], style: :bash
|
47
|
-
completion =
|
47
|
+
completion = ""
|
48
48
|
completion += builder
|
49
49
|
completion += "complete -F _#{executable_name} #{executable_name}\n"
|
50
50
|
completion
|
@@ -68,10 +68,10 @@ module Fylla
|
|
68
68
|
# @param class_options [List<Thor::Option>]
|
69
69
|
# a list of global or class level options for the current context
|
70
70
|
def map_to_completion_string(commands,
|
71
|
-
context:
|
71
|
+
context: "",
|
72
72
|
class_options: [],
|
73
73
|
style: :zsh)
|
74
|
-
builder =
|
74
|
+
builder = ""
|
75
75
|
commands.each do |command|
|
76
76
|
context_name = generate_context_name(context, command)
|
77
77
|
result = generate_completion_string(command, class_options, context_name, style)
|
@@ -88,7 +88,7 @@ module Fylla
|
|
88
88
|
# current command we are generating documentation for
|
89
89
|
def generate_context_name(context, command)
|
90
90
|
command_name = if command.name.nil? || command.name.empty?
|
91
|
-
|
91
|
+
""
|
92
92
|
else
|
93
93
|
"_#{command.name}"
|
94
94
|
end
|
@@ -96,7 +96,7 @@ module Fylla
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def generate_completion_string(command, class_options, context_name, style)
|
99
|
-
builder =
|
99
|
+
builder = ""
|
100
100
|
if command.is_a? ParsedSubcommand
|
101
101
|
class_options = parse_options((class_options + command.class_options).uniq)
|
102
102
|
builder += map_to_completion_string(command.commands,
|
@@ -123,15 +123,17 @@ module Fylla
|
|
123
123
|
# @param subcommand_map [Hash<String, Class < Thor>]
|
124
124
|
# a map indicating the subcommands and their respective classes
|
125
125
|
def recursively_find_commands(command_map, subcommand_map)
|
126
|
-
map = Hash[command_map.map {|k, v| [v, subcommand_map[k]]}]
|
126
|
+
map = Hash[command_map.map { |k, v| [v, subcommand_map[k]] }]
|
127
127
|
map.map do |command, subcommand_class|
|
128
128
|
if subcommand_class.nil?
|
129
129
|
ancestor_name = command.ancestor_name if command.respond_to? :ancestor_name
|
130
130
|
options = parse_options(command.options.values)
|
131
131
|
ParsedCommand.new(ancestor_name, command.description, command.name, options)
|
132
132
|
else
|
133
|
-
commands = recursively_find_commands subcommand_class.commands,
|
134
|
-
|
133
|
+
commands = recursively_find_commands subcommand_class.commands,
|
134
|
+
subcommand_class.subcommand_classes
|
135
|
+
ParsedSubcommand.new(command.name, command.description, commands,
|
136
|
+
subcommand_class.class_options.values)
|
135
137
|
end
|
136
138
|
end
|
137
139
|
end
|
@@ -145,7 +147,7 @@ module Fylla
|
|
145
147
|
# (see #recursively_find_commands) for more documentation
|
146
148
|
def create_command_map(command_map, subcommand_map)
|
147
149
|
command_map = recursively_find_commands command_map, subcommand_map
|
148
|
-
ParsedSubcommand.new(nil,
|
150
|
+
ParsedSubcommand.new(nil, "", command_map, class_options.values)
|
149
151
|
end
|
150
152
|
|
151
153
|
# Helper method to load an [ERB] template
|
@@ -154,7 +156,7 @@ module Fylla
|
|
154
156
|
# @param template [String] an ERB template
|
155
157
|
# @param bind [Binding] a binding to a context
|
156
158
|
def create_completion_string(template, bind)
|
157
|
-
template = ERB.new(template,
|
159
|
+
template = ERB.new(template, trim_mode: "-<>")
|
158
160
|
template.result(bind)
|
159
161
|
end
|
160
162
|
|
data/lib/fylla/parsed_option.rb
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
module Fylla
|
2
2
|
class ParsedOption
|
3
3
|
attr_accessor :aliases, :description, :name
|
4
|
-
|
5
|
-
|
4
|
+
# used just for parsing class_options recursively. Don't ever set these.
|
5
|
+
# used for erb file action
|
6
|
+
attr_reader :completion, :banner, :enum, :filter, :type, :action, :equals_type
|
6
7
|
|
7
8
|
def initialize(name, description, aliases, enum, filter, type)
|
8
9
|
@name = name
|
9
10
|
@description = description
|
10
11
|
@aliases = aliases
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
# used for switches that take values (everything, but not necessary for boolean)
|
13
|
+
@equals_type = type == :boolean ? "" : "="
|
14
|
+
@action = ""
|
15
|
+
return unless enum
|
16
|
+
|
17
|
+
case type
|
18
|
+
when :array
|
19
|
+
@action = if filter
|
20
|
+
%(: :_values -s , 'options' #{enum.join(" ")})
|
21
|
+
else
|
22
|
+
%(: :_sequence -d compadd - #{enum.join(" ")})
|
23
|
+
end
|
24
|
+
when :string
|
25
|
+
@action = %|: :(#{enum.join(" ")})|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "thor"
|
2
2
|
|
3
3
|
# Modify how Thor parses array arguments to be POSIX standard per
|
4
4
|
# getopt_long(3)
|
@@ -6,8 +6,9 @@ require 'thor'
|
|
6
6
|
module Fylla
|
7
7
|
module Thor
|
8
8
|
module Arguments
|
9
|
-
def parse_array(
|
9
|
+
def parse_array(_name)
|
10
10
|
return shift if peek.is_a?(Array)
|
11
|
+
|
11
12
|
array = []
|
12
13
|
if peek.include? ","
|
13
14
|
array.push(*shift.split(","))
|
@@ -18,4 +19,4 @@ module Fylla
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
21
|
-
end
|
22
|
+
end
|
data/lib/fylla/version.rb
CHANGED
data/lib/fylla.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "fylla/version"
|
2
|
+
require "fylla/completion_generator"
|
3
|
+
require "fylla/parsed_command"
|
4
|
+
require "fylla/parsed_subcommand"
|
5
|
+
require "fylla/completion_extension"
|
6
|
+
require "fylla/thor/extensions/comma_array_extension"
|
7
|
+
require "thor"
|
8
8
|
|
9
9
|
# We _must prepend before thor loads_ Ideally this is at require time...
|
10
10
|
::Thor::Option.prepend Fylla::Thor::Option
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fylla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Thrailkill
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,56 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.21'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.21'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.27.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.27.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.6.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.6.0
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
126
|
name: thor
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +169,7 @@ licenses:
|
|
127
169
|
metadata:
|
128
170
|
yard.run: yri
|
129
171
|
changelog_uri: https://github.com/snowe2010/fylla/blob/master/CHANGELOG.md
|
130
|
-
post_install_message:
|
172
|
+
post_install_message:
|
131
173
|
rdoc_options: []
|
132
174
|
require_paths:
|
133
175
|
- lib
|
@@ -142,9 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
184
|
- !ruby/object:Gem::Version
|
143
185
|
version: '0'
|
144
186
|
requirements: []
|
145
|
-
|
146
|
-
|
147
|
-
signing_key:
|
187
|
+
rubygems_version: 3.3.7
|
188
|
+
signing_key:
|
148
189
|
specification_version: 4
|
149
190
|
summary: Adds functions for generating autocomplete scripts for Thor applications
|
150
191
|
test_files: []
|