Skip to content

Commit ed4968c

Browse files
authored
Merge pull request #163 from github/kpaulisse-optionsref
Provide ordering within a given option weight
2 parents 9a37a47 + a2d0505 commit ed4968c

11 files changed

+23
-4
lines changed

doc/optionsref.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ Usage: octocatalog-diff [command line options]
8787
--to-puppet-binary STRING Full path to puppet binary for the to branch
8888
--from-puppet-binary STRING Full path to puppet binary for the from branch
8989
--facts-terminus STRING Facts terminus: one of yaml, facter
90+
--puppetdb-url URL PuppetDB base URL
9091
--puppetdb-ssl-ca FILENAME CA certificate that signed the PuppetDB certificate
9192
--puppetdb-ssl-client-cert FILENAME
9293
SSL client certificate to connect to PuppetDB
93-
--puppetdb-ssl-client-password PASSWORD
94-
Password for SSL client key to connect to PuppetDB
9594
--puppetdb-ssl-client-key FILENAME
9695
SSL client key to connect to PuppetDB
96+
--puppetdb-ssl-client-password PASSWORD
97+
Password for SSL client key to connect to PuppetDB
9798
--puppetdb-ssl-client-password-file FILENAME
9899
Read password for SSL client key from a file
99-
--puppetdb-url URL PuppetDB base URL
100100
--puppetdb-api-version N Version of PuppetDB API (3 or 4)
101101
--fact-override STRING1[,STRING2[,...]]
102102
Override fact globally

lib/octocatalog-diff/cli/options.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,18 @@ def self.has_weight(w) # rubocop:disable Style/PredicateName
2828
@weight = w
2929
end
3030

31+
def self.order_within_weight(w) # rubocop:disable Style/TrivialAccessors
32+
@order_within_weight = w
33+
end
34+
3135
def self.weight
32-
@weight || DEFAULT_WEIGHT
36+
if @weight && @order_within_weight
37+
@weight + (@order_within_weight / 100.0)
38+
elsif @weight
39+
@weight
40+
else
41+
DEFAULT_WEIGHT
42+
end
3343
end
3444

3545
def self.name

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# @param options [Hash] Options hash being constructed; this is modified in this method.
88
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_ssl_ca) do
99
has_weight 320
10+
order_within_weight 30
1011

1112
def parse(parser, options)
1213
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# @param options [Hash] Options hash being constructed; this is modified in this method.
77
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_ssl_client_cert) do
88
has_weight 320
9+
order_within_weight 40
910

1011
def parse(parser, options)
1112
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# @param options [Hash] Options hash being constructed; this is modified in this method.
77
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_ssl_client_key) do
88
has_weight 320
9+
order_within_weight 50
910

1011
def parse(parser, options)
1112
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# @param options [Hash] Options hash being constructed; this is modified in this method.
88
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_ca) do
99
has_weight 310
10+
order_within_weight 10
1011

1112
def parse(parser, options)
1213
parser.on('--puppetdb-ssl-ca FILENAME', 'CA certificate that signed the PuppetDB certificate') do |x|

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# @param options [Hash] Options hash being constructed; this is modified in this method.
77
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_cert) do
88
has_weight 310
9+
order_within_weight 20
910

1011
def parse(parser, options)
1112
parser.on('--puppetdb-ssl-client-cert FILENAME', 'SSL client certificate to connect to PuppetDB') do |x|

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# @param options [Hash] Options hash being constructed; this is modified in this method.
77
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_key) do
88
has_weight 310
9+
order_within_weight 30
910

1011
def parse(parser, options)
1112
parser.on('--puppetdb-ssl-client-key FILENAME', 'SSL client key to connect to PuppetDB') do |x|

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# @param options [Hash] Options hash being constructed; this is modified in this method.
88
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_cert) do
99
has_weight 310
10+
order_within_weight 35
1011

1112
def parse(parser, options)
1213
parser.on('--puppetdb-ssl-client-password PASSWORD', 'Password for SSL client key to connect to PuppetDB') do |x|

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# @param options [Hash] Options hash being constructed; this is modified in this method.
66
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_password_file) do
77
has_weight 310
8+
order_within_weight 37
89

910
def parse(parser, options)
1011
parser.on('--puppetdb-ssl-client-password-file FILENAME', 'Read password for SSL client key from a file') do |x|

0 commit comments

Comments
 (0)