Class: MeowCop::CLI
- Inherits:
-
Object
- Object
- MeowCop::CLI
- Defined in:
- lib/meowcop/cli.rb
Defined Under Namespace
Classes: Options
Constant Summary collapse
- CONFIG_FILE_NAME =
".rubocop.yml".freeze
- EXIT_SUCCESS =
0
- EXIT_FAILURE =
1
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.start(args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/meowcop/cli.rb', line 35 def self.start(args) action_name = args.shift || 'help' instance = self.new unless instance.public_methods(false).include?(action_name.to_sym) puts "Could not find command '#{action_name}'." instance.help(args) return EXIT_FAILURE end instance.public_send(action_name, args) end |
Instance Method Details
#help(_args) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/meowcop/cli.rb', line 63 def help(_args) puts <<-END Usage: meowcop <command> Commands: init Setup .rubocop.yml run Run RuboCop with MeowCop version Show version help Show help END EXIT_SUCCESS end |
#init(_args) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/meowcop/cli.rb', line 49 def init(_args) action = File.exist?(CONFIG_FILE_NAME) ? "overwritten" : "created" FileUtils.copy_file(config_file_path, CONFIG_FILE_NAME) puts "Meow! #{CONFIG_FILE_NAME} has been #{action} successfully." EXIT_SUCCESS end |
#run(args) ⇒ Object
57 58 59 60 61 |
# File 'lib/meowcop/cli.rb', line 57 def run(args) require 'rubocop' RuboCop::CLI.new.run(['--config', config_file_path, *args]) end |
#version(_args) ⇒ Object
77 78 79 80 81 |
# File 'lib/meowcop/cli.rb', line 77 def version(_args) puts VERSION EXIT_SUCCESS end |