Skip to content

Commit

Permalink
[#157] added option --silent to few commands
Browse files Browse the repository at this point in the history
  • Loading branch information
the38th committed Sep 6, 2022
1 parent 20895f2 commit d2671f2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/uffizzi/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def version
desc 'login [OPTIONS]', 'Login to Uffizzi to view and manage your previews'
method_option :server, required: false, aliases: '-s'
method_option :username, required: false, aliases: '-u'
method_option :silent, required: false, type: :boolean
def login
require_relative 'cli/login'
Login.new(options).run
Expand All @@ -27,6 +28,7 @@ def login
desc 'login_by_identity_token [OPTIONS]', 'Login or register to Uffizzi to view and manage your previews'
method_option :server, required: true, aliases: '-s'
method_option :token, required: true, aliases: '-t'
method_option :silent, required: false, type: :boolean
def login_by_identity_token
require_relative 'cli/login_by_identity_token'
LoginByIdentityToken.new(options).run
Expand All @@ -52,6 +54,7 @@ def logout
subcommand 'preview', Cli::Preview

desc 'connect', 'connect'
method_option :silent, required: false, type: :boolean
require_relative 'cli/connect'
subcommand 'connect', Cli::Connect

Expand Down
2 changes: 2 additions & 0 deletions lib/uffizzi/cli/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def get_value(property)
end

desc 'set [PROPERTY] [VALUE]', 'Sets the value of the specified option'
method_option :silent, required: false, type: :boolean
def set(property, value)
run('set', property, value)
end
Expand Down Expand Up @@ -78,6 +79,7 @@ def handle_get_command(property)
end

def handle_set_command(property, value)
Uffizzi.ui.disable_stdout if @options[:silent]
ConfigFile.write_option(property.to_sym, value)
Uffizzi.ui.say("Updated property [#{property}]")
end
Expand Down
6 changes: 6 additions & 0 deletions lib/uffizzi/cli/connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def list_credentials
method_option :username, type: :string, aliases: :u
method_option :password, type: :string, aliases: :p
def docker_hub
Uffizzi.ui.disable_stdout if options[:silent]
type = Uffizzi.configuration.credential_types[:dockerhub]
credential_exists = credential_exists?(type)
handle_existing_credential_options('docker-hub') if credential_exists
Expand Down Expand Up @@ -57,6 +58,7 @@ def docker_hub
method_option :username, type: :string, aliases: :u
method_option :password, type: :string, aliases: :p
def docker_registry
Uffizzi.ui.disable_stdout if @options[:silent]
type = Uffizzi.configuration.credential_types[:docker_registry]
credential_exists = credential_exists?(type)
handle_existing_credential_options('docker-registry') if credential_exists
Expand Down Expand Up @@ -89,6 +91,7 @@ def docker_registry
method_option :username, type: :string, aliases: :u
method_option :password, type: :string, aliases: :p
def acr
Uffizzi.ui.disable_stdout if @options[:silent]
type = Uffizzi.configuration.credential_types[:azure]
credential_exists = credential_exists?(type)
handle_existing_credential_options('acr') if credential_exists
Expand Down Expand Up @@ -121,6 +124,7 @@ def acr
method_option :id, type: :string
method_option :secret, type: :string, aliases: :s
def ecr
Uffizzi.ui.disable_stdout if @options[:silent]
type = Uffizzi.configuration.credential_types[:amazon]
credential_exists = credential_exists?(type)
handle_existing_credential_options('ecr') if credential_exists
Expand Down Expand Up @@ -150,6 +154,7 @@ def ecr
desc: 'Skip raising an error within check the credential'
method_option :update_credential_if_exists, type: :boolean, default: false
def gcr(credential_file_path = nil)
Uffizzi.ui.disable_stdout if @options[:silent]
type = Uffizzi.configuration.credential_types[:google]
credential_exists = credential_exists?(type)
handle_existing_credential_options('gcr') if credential_exists
Expand Down Expand Up @@ -179,6 +184,7 @@ def gcr(credential_file_path = nil)
method_option :username, type: :string, aliases: :u
method_option :token, type: :string, aliases: :t
def ghcr
Uffizzi.ui.disable_stdout if @options[:silent]
type = Uffizzi.configuration.credential_types[:github_registry]
credential_exists = credential_exists?(type)
handle_existing_credential_options('ghcr') if credential_exists
Expand Down
1 change: 1 addition & 0 deletions lib/uffizzi/cli/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize(options)
end

def run
Uffizzi.ui.disable_stdout if @options[:silent]
Uffizzi.ui.say('Login to Uffizzi server.')
server = set_server

Expand Down
1 change: 1 addition & 0 deletions lib/uffizzi/cli/login_by_identity_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def initialize(options)
end

def run
Uffizzi.ui.disable_stdout if @options[:silent]
token = @options[:token]
server = @options[:server]
params = prepare_request_params(token)
Expand Down

0 comments on commit d2671f2

Please sign in to comment.