Skip to content

Commit

Permalink
Merge pull request #163 from github/kpaulisse-optionsref
Browse files Browse the repository at this point in the history
Provide ordering within a given option weight
  • Loading branch information
kpaulisse authored Nov 16, 2017
2 parents 9a37a47 + a2d0505 commit ed4968c
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions doc/optionsref.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ Usage: octocatalog-diff [command line options]
--to-puppet-binary STRING Full path to puppet binary for the to branch
--from-puppet-binary STRING Full path to puppet binary for the from branch
--facts-terminus STRING Facts terminus: one of yaml, facter
--puppetdb-url URL PuppetDB base URL
--puppetdb-ssl-ca FILENAME CA certificate that signed the PuppetDB certificate
--puppetdb-ssl-client-cert FILENAME
SSL client certificate to connect to PuppetDB
--puppetdb-ssl-client-password PASSWORD
Password for SSL client key to connect to PuppetDB
--puppetdb-ssl-client-key FILENAME
SSL client key to connect to PuppetDB
--puppetdb-ssl-client-password PASSWORD
Password for SSL client key to connect to PuppetDB
--puppetdb-ssl-client-password-file FILENAME
Read password for SSL client key from a file
--puppetdb-url URL PuppetDB base URL
--puppetdb-api-version N Version of PuppetDB API (3 or 4)
--fact-override STRING1[,STRING2[,...]]
Override fact globally
Expand Down
12 changes: 11 additions & 1 deletion lib/octocatalog-diff/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ def self.has_weight(w) # rubocop:disable Style/PredicateName
@weight = w
end

def self.order_within_weight(w) # rubocop:disable Style/TrivialAccessors
@order_within_weight = w
end

def self.weight
@weight || DEFAULT_WEIGHT
if @weight && @order_within_weight
@weight + (@order_within_weight / 100.0)
elsif @weight
@weight
else
DEFAULT_WEIGHT
end
end

def self.name
Expand Down
1 change: 1 addition & 0 deletions lib/octocatalog-diff/cli/options/puppet_master_ssl_ca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_ssl_ca) do
has_weight 320
order_within_weight 30

def parse(parser, options)
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_ssl_client_cert) do
has_weight 320
order_within_weight 40

def parse(parser, options)
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_ssl_client_key) do
has_weight 320
order_within_weight 50

def parse(parser, options)
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
Expand Down
1 change: 1 addition & 0 deletions lib/octocatalog-diff/cli/options/puppetdb_ssl_ca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_ca) do
has_weight 310
order_within_weight 10

def parse(parser, options)
parser.on('--puppetdb-ssl-ca FILENAME', 'CA certificate that signed the PuppetDB certificate') do |x|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_cert) do
has_weight 310
order_within_weight 20

def parse(parser, options)
parser.on('--puppetdb-ssl-client-cert FILENAME', 'SSL client certificate to connect to PuppetDB') do |x|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_key) do
has_weight 310
order_within_weight 30

def parse(parser, options)
parser.on('--puppetdb-ssl-client-key FILENAME', 'SSL client key to connect to PuppetDB') do |x|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_cert) do
has_weight 310
order_within_weight 35

def parse(parser, options)
parser.on('--puppetdb-ssl-client-password PASSWORD', 'Password for SSL client key to connect to PuppetDB') do |x|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_ssl_client_password_file) do
has_weight 310
order_within_weight 37

def parse(parser, options)
parser.on('--puppetdb-ssl-client-password-file FILENAME', 'Read password for SSL client key from a file') do |x|
Expand Down
1 change: 1 addition & 0 deletions lib/octocatalog-diff/cli/options/puppetdb_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_url) do
has_weight 310
order_within_weight 1

def parse(parser, options)
parser.on('--puppetdb-url URL', 'PuppetDB base URL') do |url|
Expand Down

0 comments on commit ed4968c

Please sign in to comment.