fylla 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14e4ab52af2d12b3d0078c3c0451da1a28c0e795c06b9e9867f6188e849c304a
4
- data.tar.gz: 8267d2624d22df38cdce36e8b9f245458ec43b6659634e02a5970eaa099fef21
3
+ metadata.gz: 314b5586ed38f48c0ddaec4a02725f2c8aac75e53c46be9bd9c49ce3f8732584
4
+ data.tar.gz: ad49c03801fdfef68904a27184ea0395b99a4c89ed14ebcf1a5d6392a73022d7
5
5
  SHA512:
6
- metadata.gz: 0ff83b9fcc93795be5fc9feadc6dc4cc04cf3fbc178a6430a7f2602e2363d7d0ab5961430f78da4bad91957846690b648638e317ac019f272e5d184272a79971
7
- data.tar.gz: f92146028038df7a651eb82579bc5dc437032fb554e1518290cc2f9c40319fd43fa8204bb914b0e4c8bbf0c9c46db09dc9e7da28c8a444e465b4d4b998b0061b
6
+ metadata.gz: 4fa98a04457e512452f91bad2014b14887735f580e35d21398345371349c28b590f6f9f32dfb4e7338525f6b3b15402880c0005e8186d6c4978e4ac7eeaf113f
7
+ data.tar.gz: c2a727408a06d17d17d8f6a75e79efeb04e8923b7a8ff30064f26a560d3db8d518244cdb2a923814009227657b36f21337ac114a475bf3d87d5979e0e34f2184
@@ -176,7 +176,7 @@ module Fylla
176
176
  def parse_options(options)
177
177
  options.map do |opt|
178
178
  description = opt.completion || opt.description || opt.banner || opt.name.to_s.upcase
179
- ParsedOption.new(opt.name, description, opt.aliases, opt.enum, opt.filter)
179
+ ParsedOption.new(opt.name, description, opt.aliases, opt.enum, opt.filter, opt.type)
180
180
  end
181
181
  end
182
182
  end
@@ -2,21 +2,10 @@ function _<%= @executable_name %><%= context_name %> {
2
2
  _arguments \
3
3
  <%- unless command.options.nil? -%>
4
4
  <%- command.options.each do |option| -%>
5
- <%- enums_exist = option.enum -%>
6
- <%- filtered = option.filter -%>
7
5
  <%- desc = option.description.gsub('"', %q|\\"|) -%>
8
- <%- if enums_exist -%>
9
- <%- if filtered -%>
10
- <%- actions = ": :_values -s , 'options' #{option.enum.join(' ')}" -%>
11
- <%- else -%>
12
- <%- actions = ": :_sequence -d compadd - #{option.enum.join(' ')}" -%>
13
- <%- end -%>
14
- "--<%= option.name %>=[<%= desc %>]<%= actions %>" \
15
- <%- else -%>
16
- "--<%= option.name %>[<%= desc %>]" \
17
- <%- end -%>
6
+ "--<%= option.name %><%= option.equals_type %>[<%= desc %>]<%= option.action %>" \
18
7
  <%- option.aliases.each do |al| -%>
19
- "-<%= al %><%= option.enum ? '=' : '' %>[<%= desc %>]<%= option.enum ? actions : '' %>" \
8
+ "-<%= al %><%= option.equals_type %>[<%= desc %>]<%= option.action %>" \
20
9
  <%- end -%>
21
10
  <%- end -%>
22
11
  <%- end -%>
@@ -1,14 +1,27 @@
1
1
  module Fylla
2
2
  class ParsedOption
3
- attr_accessor :aliases, :description, :name, :enum, :filter
4
- attr_reader :completion, :banner # used just for parsing class_options recursively. Don't ever set these.
3
+ attr_accessor :aliases, :description, :name
4
+ attr_reader :completion, :banner, :enum, :filter, :type # used just for parsing class_options recursively. Don't ever set these.
5
+ attr_reader :action, :equals_type # used for erb file action
5
6
 
6
- def initialize(name, description, aliases, enum, filter)
7
+ def initialize(name, description, aliases, enum, filter, type)
7
8
  @name = name
8
9
  @description = description
9
10
  @aliases = aliases
10
- @enum = enum || nil
11
- @filter = filter
11
+ @equals_type = type == :boolean ? '' : '=' # used for switches that take values (everything, but not necessary for boolean)
12
+ @action = ''
13
+ if enum
14
+ case type
15
+ when :array
16
+ if filter
17
+ @action = %Q|: :_values -s , 'options' #{enum.join(' ')}|
18
+ else
19
+ @action = %Q|: :_sequence -d compadd - #{enum.join(' ')}|
20
+ end
21
+ when :string
22
+ @action = %Q|: :(#{enum.join(' ')})|
23
+ end
24
+ end
12
25
  end
13
26
  end
14
27
  end
@@ -1,3 +1,3 @@
1
1
  module Fylla
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
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.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Thrailkill
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2019-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler