|
16 | 16 | # limitations under the License. |
17 | 17 | # |
18 | 18 |
|
19 | | -require_relative "base" |
20 | | -require "chef-cli/licensing/base" |
21 | | -require_relative "../configurable" |
22 | | - |
23 | | -module ChefCLI |
24 | | - module Command |
25 | | - |
26 | | - # This class will manage the license command in the chef-cli |
27 | | - class License < Base |
28 | | - |
29 | | - include Configurable |
30 | | - |
31 | | - MAIN_COMMAND_HELP = <<~HELP.freeze |
32 | | - Usage: #{ChefCLI::Dist::EXEC} license [SUBCOMMAND] |
33 | | -
|
34 | | - `#{ChefCLI::Dist::EXEC} license` command will validate the existing license |
35 | | - or will help you interactively generate new free/trial license and activate the |
36 | | - commercial license the chef team has sent you through email. |
37 | | - HELP |
38 | | - |
39 | | - SUB_COMMANDS = [ |
40 | | - { name: "list", description: "List details of the license(s) installed on the system." }, |
41 | | - { name: "add", description: "Create & install a Free/ Trial license or install a Commercial license on the system." }, |
42 | | - ].freeze |
43 | | - |
44 | | - option :chef_license_key, |
45 | | - long: "--chef-license-key LICENSE", |
46 | | - description: "New license key to accept and store in the system" |
47 | | - |
48 | | - attr_accessor :ui |
49 | | - |
50 | | - def self.banner |
51 | | - <<~BANNER |
52 | | - #{MAIN_COMMAND_HELP} |
53 | | - Subcommands: |
54 | | - #{SUB_COMMANDS.map do |c| |
55 | | - " #{c[:name].ljust(7)}#{c[:description]}" |
56 | | - end.join("\n") } |
57 | | -
|
58 | | - Options: |
59 | | - BANNER |
60 | | - end |
61 | | - |
62 | | - def initialize |
63 | | - super |
64 | | - |
65 | | - @ui = UI.new |
66 | | - end |
67 | | - |
68 | | - def run(params) |
69 | | - config_license_debug if debug? |
70 | | - remaining_args = parse_options(params) |
71 | | - return 1 unless validate_params!(remaining_args) |
72 | | - |
73 | | - if remaining_args.blank? |
74 | | - ChefCLI::Licensing::Base.validate |
75 | | - else |
76 | | - ChefCLI::Licensing::Base.send(remaining_args[0]) |
77 | | - end |
78 | | - rescue ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError |
79 | | - ui.msg("License key not fetched. Please try again.") |
80 | | - end |
81 | | - |
82 | | - def debug? |
83 | | - !!config[:debug] |
84 | | - end |
85 | | - |
86 | | - def validate_params!(args) |
87 | | - if args.length > 1 |
88 | | - ui.err("Too many arguments") |
89 | | - return false |
90 | | - end |
91 | | - |
92 | | - valid_subcommands = SUB_COMMANDS.collect { |c| c[:name] } |
93 | | - args.each do |arg| |
94 | | - next if valid_subcommands.include?(arg) |
95 | | - |
96 | | - ui.err("Invalid option: #{arg}") |
97 | | - return false |
98 | | - end |
99 | | - |
100 | | - true |
101 | | - end |
102 | | - |
103 | | - private |
104 | | - |
105 | | - def config_license_debug |
106 | | - ChefLicensing.output = ui |
107 | | - end |
108 | | - end |
109 | | - end |
110 | | -end |
| 19 | +# require_relative "base" |
| 20 | +# require "chef-cli/licensing/base" |
| 21 | +# require_relative "../configurable" |
| 22 | + |
| 23 | +# module ChefCLI |
| 24 | +# module Command |
| 25 | + |
| 26 | +# # This class will manage the license command in the chef-cli |
| 27 | +# class License < Base |
| 28 | + |
| 29 | +# include Configurable |
| 30 | + |
| 31 | +# MAIN_COMMAND_HELP = <<~HELP.freeze |
| 32 | +# Usage: #{ChefCLI::Dist::EXEC} license [SUBCOMMAND] |
| 33 | + |
| 34 | +# `#{ChefCLI::Dist::EXEC} license` command will validate the existing license |
| 35 | +# or will help you interactively generate new free/trial license and activate the |
| 36 | +# commercial license the chef team has sent you through email. |
| 37 | +# HELP |
| 38 | + |
| 39 | +# SUB_COMMANDS = [ |
| 40 | +# { name: "list", description: "List details of the license(s) installed on the system." }, |
| 41 | +# { name: "add", description: "Create & install a Free/ Trial license or install a Commercial license on the system." }, |
| 42 | +# ].freeze |
| 43 | + |
| 44 | +# option :chef_license_key, |
| 45 | +# long: "--chef-license-key LICENSE", |
| 46 | +# description: "New license key to accept and store in the system" |
| 47 | + |
| 48 | +# attr_accessor :ui |
| 49 | + |
| 50 | +# def self.banner |
| 51 | +# <<~BANNER |
| 52 | +# #{MAIN_COMMAND_HELP} |
| 53 | +# Subcommands: |
| 54 | +# #{SUB_COMMANDS.map do |c| |
| 55 | +# " #{c[:name].ljust(7)}#{c[:description]}" |
| 56 | +# end.join("\n") } |
| 57 | + |
| 58 | +# Options: |
| 59 | +# BANNER |
| 60 | +# end |
| 61 | + |
| 62 | +# def initialize |
| 63 | +# super |
| 64 | + |
| 65 | +# @ui = UI.new |
| 66 | +# end |
| 67 | + |
| 68 | +# def run(params) |
| 69 | +# config_license_debug if debug? |
| 70 | +# remaining_args = parse_options(params) |
| 71 | +# return 1 unless validate_params!(remaining_args) |
| 72 | + |
| 73 | +# if remaining_args.blank? |
| 74 | +# ChefCLI::Licensing::Base.validate |
| 75 | +# else |
| 76 | +# ChefCLI::Licensing::Base.send(remaining_args[0]) |
| 77 | +# end |
| 78 | +# rescue ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError |
| 79 | +# ui.msg("License key not fetched. Please try again.") |
| 80 | +# end |
| 81 | + |
| 82 | +# def debug? |
| 83 | +# !!config[:debug] |
| 84 | +# end |
| 85 | + |
| 86 | +# def validate_params!(args) |
| 87 | +# if args.length > 1 |
| 88 | +# ui.err("Too many arguments") |
| 89 | +# return false |
| 90 | +# end |
| 91 | + |
| 92 | +# valid_subcommands = SUB_COMMANDS.collect { |c| c[:name] } |
| 93 | +# args.each do |arg| |
| 94 | +# next if valid_subcommands.include?(arg) |
| 95 | + |
| 96 | +# ui.err("Invalid option: #{arg}") |
| 97 | +# return false |
| 98 | +# end |
| 99 | + |
| 100 | +# true |
| 101 | +# end |
| 102 | + |
| 103 | +# private |
| 104 | + |
| 105 | +# def config_license_debug |
| 106 | +# ChefLicensing.output = ui |
| 107 | +# end |
| 108 | +# end |
| 109 | +# end |
| 110 | +# end |
0 commit comments