lib/command/base.rb in cpl-1.2.0 vs lib/command/base.rb in cpl-1.3.0

- old
+ new

@@ -1,11 +1,15 @@ # frozen_string_literal: true +require_relative "../core/helpers" + module Command class Base # rubocop:disable Metrics/ClassLength attr_reader :config + include Helpers + # Used to call the command (`cpl NAME`) # NAME = "" # Displayed when running `cpl help` or `cpl help NAME` (defaults to `NAME`) USAGE = "" # Throws error if `true` and no arguments are passed to the command @@ -13,10 +17,13 @@ REQUIRES_ARGS = false # Default arguments if none are passed to the command DEFAULT_ARGS = [].freeze # Options for the command (use option methods below) OPTIONS = [].freeze + # Does not throw error if `true` and extra options + # that are not specified in `OPTIONS` are passed to the command + ACCEPTS_EXTRA_OPTIONS = false # Displayed when running `cpl help` # DESCRIPTION = "" # Displayed when running `cpl help NAME` # LONG_DESCRIPTION = "" # Displayed along with `LONG_DESCRIPTION` when running `cpl help NAME` @@ -120,10 +127,22 @@ required: required } } end + def self.domain_option(required: false) + { + name: :domain, + params: { + banner: "DOMAIN_NAME", + desc: "Domain name", + type: :string, + required: required + } + } + end + def self.upstream_token_option(required: false) { name: :upstream_token, params: { aliases: ["-t"], @@ -212,9 +231,21 @@ name: :trace, params: { desc: "Shows trace of API calls. WARNING: may contain sensitive data", type: :boolean, required: required + } + } + end + + def self.clean_on_failure_option(required: false) + { + name: :clean_on_failure, + params: { + desc: "Deletes workload when finished with failure (success always deletes)", + type: :boolean, + required: required, + default: true } } end def self.all_options