commander-openflighthpc 1.1.2 → 1.2.0

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: a40df29e6a019c3ff4bac1776e2752ceefd52ac7cf79f5e6d5d99ec32266c59b
4
- data.tar.gz: 0fb111ee4776fd2fbcb359781e740f30572b7b0f6fb9474ddc014b11aa6c8da9
3
+ metadata.gz: f2bd1303f7a91cad5cadac934d35ee270a9b2441db7c37685a669b000f8782b5
4
+ data.tar.gz: '004078c3f1ee373463a37430dbc18207747907e12bc2d4b479903e1f08d1f200'
5
5
  SHA512:
6
- metadata.gz: 27a69ae0244b52ddd67288b77a54cda2b0e54bc115c2212960fed7761d7aefe75fc86fb83114b328283c136aab097ae8cfa28f8be061d68891ed1900b87ff4d9
7
- data.tar.gz: 87a25ff68ff7c522989e4c67002b6903433af6ace6a12779d23855f1be4e7d2b5257f33bd452ac708a439344f83c51ba911014b117dac90f01bfd144c8bd8714
6
+ metadata.gz: d2a0c2e988bcec7ce6d0a811777588684652b762c3886a4b7bbb25a79443fe924b8d726e6e576734769cbcf852f0bb1200717a5a509c3e25303846228ef28b7e
7
+ data.tar.gz: b62447900fdf781e69886d657c5470dc59ca935daeee043c08308689f5b7f24375535261f3f28f311754943a8ce8efbaf75d04ac4a0e53430f7dfa9cafeca424
@@ -4,6 +4,7 @@ require 'commander/patches/decimal-integer'
4
4
  require 'commander/patches/validate_inputs'
5
5
  require 'commander/patches/option_defaults'
6
6
  require 'commander/patches/help_formatter_binding'
7
+ require 'commander/patches/priority_sort'
7
8
 
8
9
  OptionParser.prepend Commander::Patches::ImplicitShortTags
9
10
  OptionParser.prepend Commander::Patches::DecimalInteger
@@ -13,6 +14,7 @@ module Commander
13
14
 
14
15
  class Command
15
16
  prepend Patches::ValidateInputs
17
+ prepend Patches::PrioritySort
16
18
 
17
19
  attr_accessor :name, :examples, :syntax, :description
18
20
  attr_accessor :summary, :proxy_options, :options, :hidden
@@ -15,7 +15,7 @@
15
15
 
16
16
 
17
17
  <%= $terminal.color "SUBCOMMANDS", :bold %>:
18
- <% for name, command in @commands.sort -%>
18
+ <% @commands.values.sort.map { |c| [c.name, c] }.each do |name, command| -%>
19
19
  <% unless alias? name %>
20
20
  <%= "%-#{max_command_length}s %s" % [command.name, command.summary || command.description] -%>
21
21
  <% end -%>
@@ -8,8 +8,8 @@
8
8
  <%= cmd.description || cmd.summary %>
9
9
  <% end -%>
10
10
 
11
- <% for name, command in @commands.sort -%>
11
+ <% @commands.values.sort.map { |c| [c.name, c] }.each do |name, command| -%>
12
12
  <% unless alias? name -%>
13
13
  <%= "%-#{max_command_length}s %s" % [command.name, command.summary || command.description] %>
14
14
  <% end -%>
15
- <% end -%>
15
+ <% end -%>
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Commander
4
+ module Patches
5
+ module PrioritySort
6
+ attr_accessor :priority
7
+
8
+ def <=>(other)
9
+ # Different classes can not be compared and thus are considered
10
+ # equal in priority
11
+ return 0 unless self.class == other.class
12
+
13
+ # Sort firstly based on the commands priority
14
+ comp = (self.priority || 0) <=> (other.priority || 0)
15
+
16
+ # Fall back on name comparison if priority is equal
17
+ comp == 0 ? self.name <=> other.name : comp
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Commander
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commander-openflighthpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alces Flight Ltd
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-09-16 00:00:00.000000000 Z
13
+ date: 2019-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -143,6 +143,7 @@ files:
143
143
  - lib/commander/patches/help_formatter_binding.rb
144
144
  - lib/commander/patches/implicit-short-tags.rb
145
145
  - lib/commander/patches/option_defaults.rb
146
+ - lib/commander/patches/priority_sort.rb
146
147
  - lib/commander/patches/validate_inputs.rb
147
148
  - lib/commander/platform.rb
148
149
  - lib/commander/runner.rb