-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli
executable file
·43 lines (33 loc) · 949 Bytes
/
cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env ruby
# frozen_string_literal: true
APP_ROOT = __dir__
require 'thor'
class CLI < Thor
include Thor::Actions
def self.exit_on_failure?
true
end
desc 'migrate', 'Run migrations'
def migrate
require_relative 'config/environment'
Sequel.extension(:migration)
Sequel::Migrator.run(DB, 'migrate')
end
desc 'server', 'Run server'
def server
run('bundle exec puma')
end
desc 'style', 'Run rubocop to check style'
method_option :apply, type: :boolean, aliases: '-a', desc: 'Safe, non-destructive automatic cop fixes'
method_option :unsafe_apply, type: :boolean, aliases: '-A', desc: 'Unsafe, destructive automatic cop fixes'
def style
run('bundle exec rubocop')
run('bundle exec rubocop -a') if options.apply?
run('bundle exec rubocop -A') if options.unsafe_apply?
end
desc 'test', 'Run tests'
def test(*_args)
run('ruby -I. -Ilib test/all.rb')
end
end
CLI.start