thor-zsh_completion 0.1.2 → 0.1.4

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
  SHA1:
3
- metadata.gz: dd91ee306a415b0689fcdb5f58ad3c52f1d049e1
4
- data.tar.gz: 692e2d425ff2779550b3d2b5e0edd13de418262b
3
+ metadata.gz: 7e7f271e7920b86a3507c69dcba4f1161bfd8508
4
+ data.tar.gz: 3a43af41a8d16d7a4d8bd193a184099925ba2693
5
5
  SHA512:
6
- metadata.gz: 638a502306f9c061ee9f1d3689a497709e414227829430341aa7c66a73f9bca56a038d8882b947d3498f7d89d775f942b3914b21255de240466d4f28052e9910
7
- data.tar.gz: d17f7a4fd9339fec15f08951af2cecbef1af08147febc75e89a4c9aa1cdcc9858bff8787a30a939cab9b45a6deb8e2cd9dd2dd8d4a149954cb46def2c840b81b
6
+ metadata.gz: d734e5a168bfeb0d5d563962896d63a2ec9d718d76cf2bcbd0e5b822d38920a3747b24fbc8c1fdfe711efdb6e8dbc0366c6ce7aabb262a19f3307945e66631a0
7
+ data.tar.gz: 4a8a3da7011a7c2d33ea2d48d214ba5d5750fd4d51ab9279a66079cc970519c767cd1edcc3c5a688f9f078d42427c5f15d148abeed041b5e7836354af8e50f61
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ ### 0.1.4
2
+
3
+ Bugfixes
4
+
5
+ - support `Thor.map`. (by @Zhomart)
6
+
7
+ ### 0.1.3
8
+
9
+ Bugfixes
10
+
11
+ - fix invalid script generation bug for option description. (by @tbpgr)
12
+ - fix invalid script generation bug for not aliased option.
13
+
14
+ ### 0.1.1
15
+
16
+ Features
17
+
18
+ - support ruby 1.9.3.
19
+
20
+ ### 0.1.0
21
+
22
+ - initial release.
@@ -65,6 +65,7 @@ class Thor
65
65
  depth = prefix.size + 1
66
66
 
67
67
  source << SUBCOMMAND_FUNCTION_TEMPLATE.result(binding)
68
+
68
69
  subcommand[:subcommands].each do |subcommand|
69
70
  source << render_subcommand_function(subcommand, prefix: prefix)
70
71
  end
@@ -72,20 +73,30 @@ class Thor
72
73
  end
73
74
 
74
75
  def subcommand_metadata(thor)
75
- thor.tasks.map do |(name, command)|
76
- if subcommand_class = thor.subcommand_classes[name]
77
- subcommands = subcommand_metadata(subcommand_class)
78
- else
79
- subcommands = []
80
- end
81
- { name: command.name.gsub("_", "-"),
82
- usage: command.usage,
83
- description: command.description,
84
- options: thor.class_options.map{|_, o| option_metadata(o) } +
85
- command.options.map{|(_, o)| option_metadata(o) },
86
- subcommands: subcommands
87
- }
76
+ result = []
77
+ thor.tasks.each do |(name, command)|
78
+ aliases = thor.map.select{|_, original_name|
79
+ name == original_name
80
+ }.map(&:first)
81
+ result << generate_command_information(thor, name, command, aliases)
82
+ end
83
+ result
84
+ end
85
+
86
+ def generate_command_information(thor, name, command, aliases)
87
+ if subcommand_class = thor.subcommand_classes[name]
88
+ subcommands = subcommand_metadata(subcommand_class)
89
+ else
90
+ subcommands = []
88
91
  end
92
+ { name: hyphenate(name),
93
+ aliases: aliases.map{|a| hyphenate(a) },
94
+ usage: command.usage,
95
+ description: command.description,
96
+ options: thor.class_options.map{|_, o| option_metadata(o) } +
97
+ command.options.map{|(_, o)| option_metadata(o) },
98
+ subcommands: subcommands
99
+ }
89
100
  end
90
101
 
91
102
  def option_metadata(option)
@@ -110,6 +121,10 @@ class Thor
110
121
  "{" + names.join(",") + "}"
111
122
  end
112
123
  end
124
+
125
+ def hyphenate(s)
126
+ s.gsub("_", "-")
127
+ end
113
128
  end
114
129
  end
115
130
  end
@@ -16,6 +16,9 @@
16
16
  'subcommand' \
17
17
  <%- subcommand[:subcommands].each do |subcommand| -%>
18
18
  <%= quote(subcommand[:name] + bracket(subcommand[:description])) %> \
19
+ <%- subcommand[:aliases].each do |_alias| -%>
20
+ <%= quote(_alias + bracket(subcommand[:description])) %> \
21
+ <%- end -%>
19
22
  <%- end -%>
20
23
  ;
21
24
  ;;
@@ -27,6 +30,11 @@
27
30
  <%= subcommand[:name] %>)
28
31
  <%= function_name %>_<%= subcommand[:name] %>
29
32
  ;;
33
+ <%- subcommand[:aliases].each do |_alias| -%>
34
+ <%= _alias %>)
35
+ <%= function_name %>_<%= subcommand[:name] %>
36
+ ;;
37
+ <%- end -%>
30
38
  <%- end -%>
31
39
  *)
32
40
  # if does not match any subcommand
@@ -1,5 +1,5 @@
1
1
  class Thor
2
2
  module ZshCompletion
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_dependency "thor", "~> 0"
22
23
  spec.add_development_dependency "bundler", "~> 1.10"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
24
25
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor-zsh_completion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - labocho
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-17 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,6 +76,7 @@ files:
62
76
  - ".gitignore"
63
77
  - ".rspec"
64
78
  - ".travis.yml"
79
+ - CHANGELOG.md
65
80
  - CODE_OF_CONDUCT.md
66
81
  - Gemfile
67
82
  - LICENSE.txt