Sha256: 7a7983478fa90c67a0a609f7cf2ee40dec6862851b3619508b78ae0ca8994456

Contents?: true

Size: 1.2 KB

Versions: 20

Compression:

Stored size: 1.2 KB

Contents

module LitmusPaper
  module CLI
    class Admin
      class Force < Command
        def self.description
          "Force services up or down"
        end

        def self.build_request(options, args)
          options.merge! _default_options
          opt_parser = _extend_default_parser(options) do |opts|
            opts.banner = "Usage: litmusctl force <up|down> [service] [options]"
            opts.on("-d", "--delete", "Remove status file") do
              options[:delete] = true
            end
            opts.on("-r", "--reason=reason", String, "Reason for status file") do |reason|
              options[:reason] = reason
            end
          end

          opt_parser.parse! args
          direction, service = args
          path = service ? "/#{service}/#{direction}" : "/#{direction}"

          if options[:delete]
            request = Net::HTTP::Delete.new(path)
          else
            if !options.has_key?(:reason)
              print "Reason? "
              options[:reason] = STDIN.gets.chomp
            end
            request = Net::HTTP::Post.new(path)
            request.set_form_data('reason' => options[:reason])
          end

          request
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
litmus_paper-0.8.6 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.8.5 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.8.4 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.8.3 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.8.2 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.8.1 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.8.0 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.9 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.5 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.4 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.3 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.2 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.1 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.7.0 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.6.3 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.6.2 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.6.1 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.6.0 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.5.0 lib/litmus_paper/cli/admin/force.rb
litmus_paper-0.4.0 lib/litmus_paper/cli/admin/force.rb