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/commands/password_protect_key.rb,
lib/sym/app/password/providers/drb_provider.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.
Class Method Summary collapse
- .error(config: {}, exception: nil, type: nil, details: nil, reason: nil, comments: nil, command: nil) ⇒ Object
- .is_osx? ⇒ Boolean
- .log(level, *args, **opts) ⇒ Object
- .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 |
Class Method Details
.error(config: {}, exception: nil, type: nil, details: nil, reason: nil, comments: nil, command: nil) ⇒ Object
32 33 34 35 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 |
# File 'lib/sym/app.rb', line 32 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.) if exception && (config && config[:trace] || reason == 'Unknown Error') lines << "#{error_type.red.underlined}: #{error_details.white.on.red}\n" lines << exception.backtrace.join("\n").red.bold if config[:trace] lines << "\n" end operation = command ? "to #{command.class.short_name.to_s.humanize.downcase}" : '' reason = exception. if reason.nil? && exception lines << " error #{operation} → ".white.on.red+ " #{reason}".bold.red if reason lines << "#{comments}" if comments error_report = lines.compact.join("\n") || 'Undefined error' self.out.puts(error_report) if error_report.present? self.exit_code = 1 end |
.is_osx? ⇒ Boolean
63 64 65 |
# File 'lib/sym/app.rb', line 63 def self.is_osx? Gem::Platform.local.os.eql?('darwin') end |
.log(level, *args, **opts) ⇒ Object
28 29 30 |
# File 'lib/sym/app.rb', line 28 def self.log(level, *args, **opts) Sym::LOGGER.send(level, *args) if opts[:debug] end |
.out ⇒ Object
24 25 26 |
# File 'lib/sym/app.rb', line 24 def self.out STDERR end |
.this_os ⇒ Object
67 68 69 |
# File 'lib/sym/app.rb', line 67 def self.this_os Gem::Platform.local.os end |