Module: Shhh::App

Defined in:
lib/shhh/app.rb,
lib/shhh/app/cli.rb,
lib/shhh/app/args.rb,
lib/shhh/app/keychain.rb,
lib/shhh/app/commands.rb,
lib/shhh/app/output/file.rb,
lib/shhh/app/input/handler.rb,
lib/shhh/app/output/stdout.rb,
lib/shhh/app/commands/command.rb,
lib/shhh/app/commands/show_help.rb,
lib/shhh/app/commands/print_key.rb,
lib/shhh/app/private_key/handler.rb,
lib/shhh/app/private_key/detector.rb,
lib/shhh/app/commands/open_editor.rb,
lib/shhh/app/private_key/decryptor.rb,
lib/shhh/app/commands/generate_key.rb,
lib/shhh/app/commands/show_version.rb,
lib/shhh/app/commands/show_examples.rb,
lib/shhh/app/commands/encrypt_decrypt.rb,
lib/shhh/app/private_key/base64_decoder.rb,
lib/shhh/app/commands/delete_keychain_item.rb

Overview

The App Module is responsible for handing user input and executing commands. Central class in this module is the CLI class.

Methods in this module are responsible for reporting errors and maintaining the future exit code class-global variable.

It also contains several helpers that enable some additional functionality on Mac OS-X (such as using KeyChain for storing encryption keys).

Defined Under Namespace

Modules: Commands, Input, Output, PrivateKey Classes: Args, CLI, KeyChain

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.exit_codeObject

Returns the value of attribute exit_code


16
17
18
# File 'lib/shhh/app.rb', line 16

def exit_code
  @exit_code
end

Class Method Details

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


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/shhh/app.rb', line 25

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)

40
41
42
# File 'lib/shhh/app.rb', line 40

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

.outObject


21
22
23
# File 'lib/shhh/app.rb', line 21

def self.out
  STDERR
end

.this_osObject


43
44
45
# File 'lib/shhh/app.rb', line 43

def self.this_os
  Gem::Platform.local.os
end