Sha256: bc3169e9ab31a336d7829687b5bd92cb46b6ba0579895ec662194500f5f5d369

Contents?: true

Size: 778 Bytes

Versions: 4

Compression:

Stored size: 778 Bytes

Contents

# encoding: utf-8

module GithubCLI
  module DSL
    @@program_name = $0.split(/\//)[-1]
    @@error_block  = nil

    # Defines a program name.
    #
    def program_name(name=nil)
      if name
        @@program_name = name
      end
      @@program_name
    end

    # Defines behaviour on error to emit consistent type.
    #
    def on_error
      yield
    rescue Exception => error
      handle_error(error)
    end

    def handle_error(error)
      case error
      when Github::Error::NotFound
        terminal.newline
        ui.error 'Resource Not Found'
        terminal.newline
      else
        raise GithubCLI::GithubCLIError, "Rescued: #{error}"
      end
    end

    def before(&block)
    end

    def configure(&block)
    end

  end # DSL
end # GithubCLI

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_cli-0.6.1 lib/github_cli/dsl.rb
github_cli-0.6.0 lib/github_cli/dsl.rb
github_cli-0.5.9 lib/github_cli/dsl.rb
github_cli-0.5.8 lib/github_cli/dsl.rb