-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathac-start
More file actions
executable file
·77 lines (62 loc) · 2.55 KB
/
Copy pathac-start
File metadata and controls
executable file
·77 lines (62 loc) · 2.55 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env ruby
# ac-start [<name>] - start backend service based on folder+name
require "colorize"
require "optimist"
require "yaml"
$:.unshift(File.expand_path("~/bin/lib"))
require "dbrady_cli"
String.disable_colorization unless $stdout.tty?
class Application
include DbradyCli
def run
@opts = Optimist.options do
banner <<BANNER
ac-start [<name>] - start backend service based on folder+name
ac-start looks at the current directory to know the correct service to start,
e.g. in the kipper folder it will return bin/rails server --port=3002 or even
`test -f ./bin/rails && ./bin/rails "#@" || bundle exec rails "#@"`. Multiple
services can be defined for each path by giving them a separate name,
e.g. `ac-start rails` could run the previous command, while ac-start q could
start `bundle exec sidekiq`.
Options:
BANNER
opt :debug, "Print extra debug info", default: false
opt :pretend, "Print commands but do not run them", default: false
opt :verbose, "Run with verbose output (overrides --quiet)", default: false
opt :quiet, "Run with minimal output", default: false
# @ignore_invalid_options = true # no error given if you call this with other options (good for passthru)
# plural types or type in [array] means multiple VALUES for this
# arg, but --arg can only appear once
# multi: true means the --arg can appear multiple times, and
# each element will be of the type indicated.
# If you specify both a plural type AND multi, you will get an
# array of arrays. See "batches" below.
#
# opt :sizes, type: :ints
# opt :names, default: [String]
# opt :file, type: :string, multi: true
# opt :batches, type: :strings, multi: true
#
# How you would call these:
# --sizes 8 9 9 # [8, 9, 9]
# --names Alice Bob Carol # ["Alice", "Bob", "Carol"]
# --file=1.txt --file=2.txt # ["1.txt", "2.txt"]
# --batches a b c --batches d e # [["a","b","c"], ["d","e"]]
# CONSTRAINTS: See https://www.manageiq.org/optimist/
#
# depends : # You may specify AT MOST one
# conflicts :cat, :dog, :rat # You may specify at most one
# either :left, :right, :center # You MUST specify EXACTLY one
end
opts[:quiet] = !opts[:verbose] if opts[:verbose_given]
puts opts.sort.to_h.inspect if debug?
run!
end
# End of Boilerplate. Actual script goes here.
def run!
puts "You are currently in #{Dir.pwd}"
end
end
if __FILE__ == $0
Application.new.run
end