Module: Sym::App
- Defined in:
- lib/sym/app.rb,
lib/sym/app/cli.rb,
lib/sym/app/args.rb,
lib/sym/app/output.rb,
lib/sym/app/cli_slop.rb,
lib/sym/app/commands.rb,
lib/sym/app/keychain.rb,
lib/sym/app/short_name.rb,
lib/sym/app/output/base.rb,
lib/sym/app/output/file.rb,
lib/sym/app/output/noop.rb,
lib/sym/app/input/handler.rb,
lib/sym/app/output/stdout.rb,
lib/sym/app/password/cache.rb,
lib/sym/app/commands/decrypt.rb,
lib/sym/app/commands/encrypt.rb,
lib/sym/app/commands/print_key.rb,
lib/sym/app/commands/show_help.rb,
lib/sym/app/password/providers.rb,
lib/sym/app/private_key/handler.rb,
lib/sym/app/commands/open_editor.rb,
lib/sym/app/private_key/detector.rb,
lib/sym/app/commands/base_command.rb,
lib/sym/app/commands/generate_key.rb,
lib/sym/app/commands/show_version.rb,
lib/sym/app/private_key/decryptor.rb,
lib/sym/app/commands/show_examples.rb,
lib/sym/app/commands/bash_completion.rb,
lib/sym/app/commands/keychain_add_key.rb,
lib/sym/app/private_key/base64_decoder.rb,
lib/sym/app/private_key/key_source_check.rb,
lib/sym/app/commands/password_protect_key.rb,
lib/sym/app/password/providers/memcached_provider.rb
Overview
The App Module is responsible for handing user input and executing commands. Central class in this module is the CLI class. However, it is recommended that ruby integration with the App module functionality is done via the Application 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: CLISlop, Commands, Input, Output, Password, PrivateKey, ShortName Classes: Args, CLI, KeyChain
Class Attribute Summary collapse
-
.exit_code ⇒ Object
Returns the value of attribute exit_code.
-
.stderr ⇒ Object
Returns the value of attribute stderr.
-
.stdin ⇒ Object
Returns the value of attribute stdin.
-
.stdout ⇒ Object
Returns the value of attribute stdout.
Class Method Summary collapse
- .error(config: {}, exception: nil, type: nil, details: nil, reason: nil, comments: nil, command: nil) ⇒ Object
- .log(level, *args, **opts) ⇒ Object
- .osx? ⇒ Boolean
- .out ⇒ Object
- .this_os ⇒ Object
Class Attribute Details
.exit_code ⇒ Object
Returns the value of attribute exit_code.
19 20 21 |
# File 'lib/sym/app.rb', line 19 def exit_code @exit_code end |
.stderr ⇒ Object
Returns the value of attribute stderr.
19 20 21 |
# File 'lib/sym/app.rb', line 19 def stderr @stderr end |
.stdin ⇒ Object
Returns the value of attribute stdin.
19 20 21 |
# File 'lib/sym/app.rb', line 19 def stdin @stdin end |
.stdout ⇒ Object
Returns the value of attribute stdout.
19 20 21 |
# File 'lib/sym/app.rb', line 19 def stdout @stdout end |
Class Method Details
.error(config: {}, exception: nil, type: nil, details: nil, reason: nil, comments: nil, command: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sym/app.rb', line 36 def self.error(config: {}, exception: nil, type: nil, details: nil, reason: nil, comments: nil, command: nil) lines = [] error_type = "#{type || exception.class.name}" error_details = (details || exception.) operation = command ? "to #{command.class.short_name.to_s.humanize.downcase}" : '' reason = exception. if exception if exception && ((config && config[:trace]) || reason == 'Unknown Error') lines << ("#{error_type.bold.red}:\n#{error_details.red.italic}\n" + ''.normal) lines << exception.backtrace.join("\n").red.bold if config[:trace] lines << "\n" else lines << "#{" ✖ Sym Error #{operation}:".bold.red}#{(reason ? " #{reason} ".red.italic: " #{error_details}")[0..70]}#{' '.normal}\n" lines << "#{comments}" if comments end error_report = lines.compact.join("\n") || 'Undefined error' self.out.puts(error_report) if error_report.present? self.exit_code = 1 end |
.log(level, *args, **opts) ⇒ Object
32 33 34 |
# File 'lib/sym/app.rb', line 32 def self.log(level, *args, **opts) Sym::Constants::Log::LOG.send(level, *args) if opts[:debug] end |
.osx? ⇒ Boolean
67 68 69 |
# File 'lib/sym/app.rb', line 67 def self.osx? Gem::Platform.local.os.eql?('darwin') end |
.out ⇒ Object
28 29 30 |
# File 'lib/sym/app.rb', line 28 def self.out self.stderr end |
.this_os ⇒ Object
71 72 73 |
# File 'lib/sym/app.rb', line 71 def self.this_os Gem::Platform.local.os end |