-
Notifications
You must be signed in to change notification settings - Fork 1
/
rubric
executable file
·204 lines (175 loc) · 4.93 KB
/
rubric
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env ruby
require 'gli'
begin # XXX: Remove this begin/rescue before distributing your app
require 'rubric'
rescue LoadError
STDERR.puts "In development, you need to use `bundle exec bin/todo` to run your app"
STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
STDERR.puts "Feel free to remove this message from bin/todo now"
exit 64
end
include GLI::App
program_desc 'Rubric helps you name things. Like a cat or a child or a project or a car or your novel or whatever'
version Rubric::VERSION
# desc 'Describe some switch here'
# switch [:s,:switch]
# desc 'Describe some flag here'
# default_value 'the default'
# arg_name 'The name of the argument'
# flag [:f,:flagname]
def rubric_list
rubric_list = [ "rocket",
"laser",
"dinosaur",
"old people",
"tiger",
"chicken",
"steel",
"crystal",
"engine",
"lady",
"baby",
"rhino",
"panda",
"apocalypse",
"zombie",
"ninja",
"harrison ford",
"space",
"underpants",
"future",
"robot",
"chocolate",
"shark",
"jet",
"gun",
"guitar solo",
"beard",
"sparkle",
"fire",
"monkey",
"cyber",
"fist",
"unicorn",
"mustache",
"juice",
"winning",
"charlie sheen",
"rapture",
"torture",
"spasm",
"bro",
"jedi",
"toupee",
"cheeseburger",
"Coolio",
"bone",
"Poland",
"satin",
"butter",
"muffin",
"milkshake",
"sword",
"giant",
"queen",
"bear",
"rainbow",
"tornado",
"lips",
"carrot",
"donut",
"fraternity",
"trophy",
"penguin",
"shake weight",
"snuggie",
"bacon",
"explosion",
"womb",
"rampage",
"gorilla",
]
end
def phrase_list
["The rubric is infallible", "Jumanji", "Unggggh", "Stop it", "Sigh", "SHAZAM!"]
end
desc 'Get will fetch you a name from the rubric'
arg_name 'Describe arguments to get here'
command :get do |c|
c.desc "Say it, don't spray it"
c.switch [:s, :say]
c.desc "Copy the rubric name to the pasteboard"
c.switch [:c, :copy]
c.desc 'How many do you want?'
c.default_value '1'
c.flag [:n, :number]
c.action do |global_options,options,args|
number = options[:n].to_i
def get_rubric
rubric = rubric_list.sample + " " + rubric_list.sample
rubric
end
def get_phrase
phrase = phrase_list.sample
phrase
end
if number > 1
rubric_list = []
number.times do
rubric_inst = get_rubric
phrase_inst = get_phrase
result = phrase_inst + ": " + rubric_inst
rubric_list << rubric_inst
puts result
if options[:s]
system "say #{result}"
end
end
if options[:c]
joined_rubric_list = rubric_list.join(", ")
system "echo #{joined_rubric_list} | pbcopy"
puts "Copied #{joined_rubric_list}"
end
else
rubric_inst = get_rubric
phrase_inst = get_phrase
result = phrase_inst + ": " + rubric_inst
puts result
if options[:s]
system "say #{result}"
end
if options[:c]
system "echo #{rubric_inst} | pbcopy"
puts "Copied #{rubric_inst}"
end
end
end
end
desc 'List the words in the rubric'
arg_name 'No args'
command :list do |c|
c.action do |global_options,options,args|
rubric_list.each do |name|
puts name
end
end
end
pre do |global,command,options,args|
# Pre logic here
# Return true to proceed; false to abourt and not call the
# chosen command
# Use skips_pre before a command to skip this block
# on that command only
true
end
post do |global,command,options,args|
# Post logic here
# Use skips_post before a command to skip this
# block on that command only
end
on_error do |exception|
# Error logic here
# return false to skip default error handling
true
end
exit run(ARGV)