module Wpxf::Cli::Creds
A mixin to provide functions to interact with credentials stored in the database.
Public Instance Methods
creds(*args)
click to toggle source
# File lib/wpxf/cli/creds.rb, line 44 def creds(*args) return list_credentials if args.length.zero? case args[0] when '-d' delete_credential(args[1]) else print_warning 'Invalid option for "creds"' end end
delete_credential(id)
click to toggle source
# File lib/wpxf/cli/creds.rb, line 7 def delete_credential(id) item = Wpxf::Models::Credential.first( id: id.to_i, workspace: active_workspace ) unless item.nil? item.destroy return print_good "Deleted credential #{id}" end print_bad "Could not find credential #{id} in the current workspace" end
list_credentials()
click to toggle source
# File lib/wpxf/cli/creds.rb, line 21 def list_credentials rows = [] rows.push( id: 'ID', host: 'Host', username: 'Username', password: 'Password', type: 'Type' ) Wpxf::Models::Credential.where(workspace: active_workspace).each do |cred| rows.push( id: cred.id, host: "#{cred.host}:#{cred.port}", username: cred.username, password: cred.password, type: cred.type ) end print_table rows end