Module: Secrets::App

Defined in:
lib/secrets/app.rb,
lib/secrets/app/cli.rb,
lib/secrets/app/commands.rb,
lib/secrets/app/keychain.rb,
lib/secrets/app/outputs/to_file.rb,
lib/secrets/app/commands/command.rb,
lib/secrets/app/password_handler.rb,
lib/secrets/app/outputs/to_stdout.rb,
lib/secrets/app/commands/show_help.rb,
lib/secrets/app/commands/open_editor.rb,
lib/secrets/app/commands/generate_key.rb,
lib/secrets/app/commands/show_version.rb,
lib/secrets/app/commands/show_examples.rb,
lib/secrets/app/commands/encrypt_decrypt.rb,
lib/secrets/app/commands/delete_keychain_key.rb

Overview

This module is responsible for printing pretty errors and maintaining the future exit code class-global variable.

Defined Under Namespace

Modules: Commands, Outputs Classes: CLI, KeyChain, PasswordHandler

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.exit_codeObject

Returns the value of attribute exit_code.



12
13
14
# File 'lib/secrets/app.rb', line 12

def exit_code
  @exit_code
end

Class Method Details

.error(config: {}, exception: nil, type: nil, details: nil, reason: nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/secrets/app.rb', line 21

def self.error(
  config: {},
  exception: nil,
  type: nil,
  details: nil,
  reason: nil)

  self.out.puts([\
                "#{(type || exception.class.name).titleize}:".red.bold.underlined +
                (sprintf '  %s', details || exception.message).red.italic,
                reason ? "\n#{reason.blue.bold.italic}" : nil].compact.join("\n"))
  self.out.puts "\n" + exception.backtrace.join("\n").bold.red if exception && config && config[:trace]
  self.exit_code = 1
end

.is_osx?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/secrets/app.rb', line 36

def self.is_osx?
  Gem::Platform.local.os.eql?('darwin')
end

.outObject



17
18
19
# File 'lib/secrets/app.rb', line 17

def self.out
  STDERR
end