lib/command/base.rb in cpl-1.1.2 vs lib/command/base.rb in cpl-1.2.0
- old
+ new
@@ -21,10 +21,12 @@
# LONG_DESCRIPTION = ""
# Displayed along with `LONG_DESCRIPTION` when running `cpl help NAME`
EXAMPLES = ""
# If `true`, hides the command from `cpl help`
HIDE = false
+ # Whether or not to show key information like ORG and APP name in commands
+ WITH_INFO_HEADER = true
NO_IMAGE_AVAILABLE = "NO_IMAGE_AVAILABLE"
def initialize(config)
@config = config
@@ -36,10 +38,14 @@
classname = File.read(file).match(/^\s+class (\w+) < Base($| .*$)/)&.captures&.first
result[filename.to_sym] = Object.const_get("::Command::#{classname}") if classname
end
end
+ def self.common_options
+ [org_option, verbose_option, trace_option]
+ end
+
def self.org_option(required: false)
{
name: :org,
params: {
aliases: ["-o"],
@@ -101,10 +107,23 @@
required: required
}
}
end
+ def self.location_option(required: false)
+ {
+ name: :location,
+ params: {
+ aliases: ["-l"],
+ banner: "LOCATION_NAME",
+ desc: "Location name",
+ type: :string,
+ required: required
+ }
+ }
+ end
+
def self.upstream_token_option(required: false)
{
name: :upstream_token,
params: {
aliases: ["-t"],
@@ -186,10 +205,21 @@
required: required
}
}
end
+ def self.trace_option(required: false)
+ {
+ name: :trace,
+ params: {
+ desc: "Shows trace of API calls. WARNING: may contain sensitive data",
+ type: :boolean,
+ required: required
+ }
+ }
+ end
+
def self.all_options
methods.grep(/_option$/).map { |method| send(method.to_s) }
end
def self.all_options_by_key_name
@@ -237,9 +267,10 @@
latest_image_from(items, app_name: app)
end
end
def latest_image_next(app = config.app, org = config.org, commit: nil)
+ # debugger
commit ||= config.options[:commit]
@latest_image_next ||= {}
@latest_image_next[app] ||= begin
latest_image_name = latest_image(app, org)