Sha256: cdf8bdd81a361e69a4062040d0eac028880320fc8cdc7a91e23dc7bf7b66213e

Contents?: true

Size: 738 Bytes

Versions: 4

Compression:

Stored size: 738 Bytes

Contents

require 'kontena/plugin/shell/command'

module Kontena::Plugin
  module Shell
    class DebugCommand < Command
      command 'debug'
      description 'Toggle debug output'
      help 'Use debug on/off to toggle debug output.'

      completions 'on', 'off', 'api'

      def execute
        case args[1]
        when 'true', 'on', '1'
          ENV['DEBUG'] = 'true'
        when 'api'
          ENV['DEBUG'] = 'api'
        when 'off', 'false', '0'
          ENV.delete('DEBUG')
        when NilClass
          # do nothing
        else
          puts Kontena.pastel.red("Unknown argument '#{args[1]}'")
        end
        puts "Debug #{Kontena.pastel.send(*ENV['DEBUG'] ? [:green, 'on'] : [:red, 'off'])}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kontena-plugin-shell-0.2.0 lib/kontena/plugin/shell/commands/debug.rb
kontena-plugin-shell-0.1.3 lib/kontena/plugin/shell/commands/debug.rb
kontena-plugin-shell-0.1.2 lib/kontena/plugin/shell/commands/debug.rb
kontena-plugin-shell-0.1.0 lib/kontena/plugin/shell/commands/debug.rb