The project is in a healthy, maintained state
A simple gem that adds a validate_before method to Thor, allowing pre-command validations
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.24, >= 5.24.1

Runtime

~> 1.3, >= 1.3.1
 Project Readme

Thor::Validations

Thor::Validations adds a validate_before method to Thor, allowing you to perform validations before executing commands.

Installation

Add this line to your application's Gemfile:

gem 'thor-validations'

Inspiration

Thanks to https://github.com/kddnewton/thor-hollaback for the original idea.

Usage

require 'thor/validations'

class MyCommand < Thor
  include Thor::Validations

  validate_before, :deploy, :rollback do
    check_permissions
  end

  desc "deploy", "Deploy app"
  def deploy
    sleep(1)
    puts "Deploying..."
  end

  desc "rollback", "Rollback app"
  def rollback
    sleep(1)
    puts "Rolling back..."
  end

  private

    def check_permissions
      puts "Checking permissions..."
    end

end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/benoittgt/thor-validations.

Test

ruby -Ilib:test test/**/*_test.rb

License

The gem is available as open source under the terms of the MIT License.