Skip to content

Commit 2bf1a47

Browse files
author
Kevin Paulisse
committed
Consistent sorting of equally weighted command line options
1 parent 3e670c4 commit 2bf1a47

2 files changed

Lines changed: 41 additions & 31 deletions

File tree

doc/optionsref.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,59 +64,59 @@ Usage: octocatalog-diff [command line options]
6464
--[no-]display-datatype-changes
6565
Display changes in data type even when strings match
6666
--[no-]catalog-only Only compile the catalog for the "to" branch but do not diff
67+
--[no-]from-puppetdb Pull "from" catalog from PuppetDB instead of compiling
68+
--[no-]parallel Enable or disable parallel processing
6769
--puppet-binary STRING Full path to puppet binary globally
6870
--to-puppet-binary STRING Full path to puppet binary for the to branch
6971
--from-puppet-binary STRING Full path to puppet binary for the from branch
70-
--[no-]parallel Enable or disable parallel processing
71-
--[no-]from-puppetdb Pull "from" catalog from PuppetDB instead of compiling
72-
--puppetdb-ssl-client-password-file FILENAME
73-
Read password for SSL client key from a file
72+
--facts-terminus STRING Facts terminus: one of yaml, facter
73+
--puppetdb-ssl-ca FILENAME CA certificate that signed the PuppetDB certificate
7474
--puppetdb-ssl-client-password PASSWORD
7575
Password for SSL client key to connect to PuppetDB
76-
--puppetdb-ssl-client-key FILENAME
77-
SSL client key to connect to PuppetDB
78-
--puppetdb-ssl-ca FILENAME CA certificate that signed the PuppetDB certificate
7976
--puppetdb-ssl-client-cert FILENAME
8077
SSL client certificate to connect to PuppetDB
81-
--facts-terminus STRING Facts terminus: one of yaml, facter
78+
--puppetdb-ssl-client-key FILENAME
79+
SSL client key to connect to PuppetDB
80+
--puppetdb-ssl-client-password-file FILENAME
81+
Read password for SSL client key from a file
8282
--puppetdb-url URL PuppetDB base URL
8383
--puppetdb-api-version N Version of PuppetDB API (3 or 4)
84-
--puppet-master-ssl-ca STRING
85-
Full path to CA certificate that signed the Puppet Master certificate globally
86-
--to-puppet-master-ssl-ca STRING
87-
Full path to CA certificate that signed the Puppet Master certificate for the to branch
88-
--from-puppet-master-ssl-ca STRING
89-
Full path to CA certificate that signed the Puppet Master certificate for the from branch
90-
--puppet-master-ssl-client-key STRING
91-
Full path to key file for SSL client auth to Puppet Master globally
92-
--to-puppet-master-ssl-client-key STRING
93-
Full path to key file for SSL client auth to Puppet Master for the to branch
94-
--from-puppet-master-ssl-client-key STRING
95-
Full path to key file for SSL client auth to Puppet Master for the from branch
9684
--fact-override STRING1[,STRING2[,...]]
9785
Override fact globally
9886
--to-fact-override STRING1[,STRING2[,...]]
9987
Override fact for the to branch
10088
--from-fact-override STRING1[,STRING2[,...]]
10189
Override fact for the from branch
102-
--puppet-master-ssl-client-cert STRING
103-
Full path to certificate file for SSL client auth to Puppet Master globally
104-
--to-puppet-master-ssl-client-cert STRING
105-
Full path to certificate file for SSL client auth to Puppet Master for the to branch
106-
--from-puppet-master-ssl-client-cert STRING
107-
Full path to certificate file for SSL client auth to Puppet Master for the from branch
90+
--puppet-master STRING Hostname or Hostname:PortNumber for Puppet Master globally
91+
--to-puppet-master STRING Hostname or Hostname:PortNumber for Puppet Master for the to branch
92+
--from-puppet-master STRING Hostname or Hostname:PortNumber for Puppet Master for the from branch
10893
--puppet-master-api-version STRING
10994
Puppet Master API version (2 for Puppet 3.x, 3 for Puppet 4.x) globally
11095
--to-puppet-master-api-version STRING
11196
Puppet Master API version (2 for Puppet 3.x, 3 for Puppet 4.x) for the to branch
11297
--from-puppet-master-api-version STRING
11398
Puppet Master API version (2 for Puppet 3.x, 3 for Puppet 4.x) for the from branch
114-
--puppet-master STRING Hostname or Hostname:PortNumber for Puppet Master globally
115-
--to-puppet-master STRING Hostname or Hostname:PortNumber for Puppet Master for the to branch
116-
--from-puppet-master STRING Hostname or Hostname:PortNumber for Puppet Master for the from branch
99+
--puppet-master-ssl-ca STRING
100+
Full path to CA certificate that signed the Puppet Master certificate globally
101+
--to-puppet-master-ssl-ca STRING
102+
Full path to CA certificate that signed the Puppet Master certificate for the to branch
103+
--from-puppet-master-ssl-ca STRING
104+
Full path to CA certificate that signed the Puppet Master certificate for the from branch
105+
--puppet-master-ssl-client-cert STRING
106+
Full path to certificate file for SSL client auth to Puppet Master globally
107+
--to-puppet-master-ssl-client-cert STRING
108+
Full path to certificate file for SSL client auth to Puppet Master for the to branch
109+
--from-puppet-master-ssl-client-cert STRING
110+
Full path to certificate file for SSL client auth to Puppet Master for the from branch
111+
--puppet-master-ssl-client-key STRING
112+
Full path to key file for SSL client auth to Puppet Master globally
113+
--to-puppet-master-ssl-client-key STRING
114+
Full path to key file for SSL client auth to Puppet Master for the to branch
115+
--from-puppet-master-ssl-client-key STRING
116+
Full path to key file for SSL client auth to Puppet Master for the from branch
117117
--pe-enc-url URL Base URL for Puppet Enterprise ENC endpoint
118-
--pe-enc-token-file PATH Path containing token for PE node classifier, relative or absolute
119118
--pe-enc-token TOKEN Token to access the Puppet Enterprise ENC API
119+
--pe-enc-token-file PATH Path containing token for PE node classifier, relative or absolute
120120
--pe-enc-ssl-ca FILENAME CA certificate that signed the ENC API certificate
121121
--pe-enc-ssl-client-cert FILENAME
122122
SSL client certificate to connect to PE ENC

lib/octocatalog-diff/catalog-diff/cli/options.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def self.weight
3030
@weight || DEFAULT_WEIGHT
3131
end
3232

33+
def self.name
34+
self::NAME
35+
end
36+
3337
def self.newoption(name, &block)
3438
klass = Class.new(OctocatalogDiff::CatalogDiff::Cli::Options::Option)
3539
klass.const_set('NAME', name)
@@ -66,7 +70,13 @@ def self.parse_options(argv, defaults = {})
6670
def self.option_classes
6771
files = Dir.glob(File.join(File.dirname(__FILE__), 'options', '*.rb'))
6872
files.each { |file| load file } # Populates self.classes
69-
classes.sort { |a, b| a.weight <=> b.weight }
73+
classes.sort do |a, b|
74+
[
75+
a.weight <=> b.weight,
76+
a.name.downcase <=> b.name.downcase,
77+
a.object_id <=> b.object_id
78+
].find(&:nonzero?)
79+
end
7080
end
7181

7282
# Sets up options that can be defined globally or for just one branch. For example, with a

0 commit comments

Comments
 (0)