Sha256: fb4403f723181f69031058ad49a70737838b128b86ddcc0364fdb980131d1ff4

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

require 'sym'
require 'active_support/inflector'

module Sym

  # The {Sym::App} Module is responsible for handing user input and executing commands.
  # Central class in this module is the {Sym::App::CLI} class. However, it is
  # recommended that ruby integration with the {Sym::App} module functionality
  # is done via the {Sym::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).
  #
  module App
    class << self
      attr_accessor :exit_code
    end

    self.exit_code = 0

    def self.out
      STDERR
    end

    def self.error(
      config: {},
      exception: nil,
      type: nil,
      details: nil,
      reason: nil,
      comments: 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),
                    (comments ? "\n\n#{comments}" : nil)].compact.join("\n"))
      self.out.puts "\n" + exception.backtrace.join("\n").bold.red if exception && config && config[:trace]
      self.exit_code = 1
    end

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

require 'sym/version'
require 'sym/app/short_name'

require 'sym/app/args'
require 'sym/app/cli'
require 'sym/app/commands'
require 'sym/app/keychain'
require 'sym/app/output'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sym-2.2.1 lib/sym/app.rb
sym-2.2.0 lib/sym/app.rb
sym-2.1.2 lib/sym/app.rb
sym-2.1.1 lib/sym/app.rb
sym-2.1.0 lib/sym/app.rb