Skip to content

Commit c696faf

Browse files
committed
Merge: Benitlux: fix separator between beers name and description
Pull-Request: #1861 Reviewed-by: Jean Privat <jean@pryen.org>
2 parents d667a32 + 42e5eec commit c696faf

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

contrib/benitlux/src/benitlux_daily.nit

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,19 @@ class Benitlux
8989
# Get the web page
9090
var body = download_html_page
9191

92+
if opts.verbose.value > 1 then
93+
print " # Body"
94+
print body
95+
end
96+
9297
# Parse the Web page and get the available beers
9398
var beers = parse_beers_from_html(body)
9499

100+
if opts.verbose.value > 0 then
101+
print " # Beers"
102+
print beers
103+
end
104+
95105
var db = new DB.open(db_path)
96106

97107
# Update the database with the beers of the day
@@ -112,6 +122,10 @@ class Benitlux
112122
# Set the email if desired
113123
if send_emails then
114124
var subs = db.subscribers
125+
if opts.verbose.value > 0 then
126+
print " # Subscribers"
127+
print subs
128+
end
115129
send_emails_to subs
116130
end
117131

@@ -152,9 +166,14 @@ class Benitlux
152166
var of_interest = body.substring(start, finish-start)
153167
var lines = of_interest.strip_tags.to_clean_lines
154168

169+
if opts.verbose.value > 0 then
170+
print " # Lines"
171+
print lines
172+
end
173+
155174
var beers = new HashSet[Beer]
156175
for line in lines do
157-
var parts = line.split(" - ")
176+
var parts = line.split("- ")
158177
if parts.length >= 2 then
159178
beers.add new Beer(parts[0].trim, parts[1].trim)
160179
end
@@ -202,16 +221,23 @@ redef class OptionContext
202221
# Shall we mail the mailing list?
203222
var send_emails = new OptionBool("Send emails to subscribers", "-e", "--email")
204223

224+
# Display more debug messages
225+
var verbose = new OptionCount("Display extra debug messages", "-v")
226+
205227
# Print the usage message
206228
var help = new OptionBool("Print this help message", "-h", "--help")
207229

208-
redef init do add_option(send_emails, help)
230+
redef init do add_option(send_emails, verbose, help)
231+
end
232+
233+
redef class Sys
234+
# Command line options
235+
var opts = new OptionContext
209236
end
210237

211238
# Avoid executing when running tests
212239
if "NIT_TESTING".environ == "true" then exit 0
213240

214-
var opts = new OptionContext
215241
opts.parse args
216242
if not opts.errors.is_empty or opts.help.value == true then
217243
print opts.errors.join("\n")

0 commit comments

Comments
 (0)