-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.rb
More file actions
49 lines (37 loc) · 911 Bytes
/
cli.rb
File metadata and controls
49 lines (37 loc) · 911 Bytes
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
$LOAD_PATH << './'
require 'command'
require 'search'
require 'data_parser'
module EventReporter
class CLI
EXIT_COMMANDS = ["quit", "q", "e", "exit"]
Search.new
DataParser.new
Queue.new
def self.parse_user_input(input)
[ input.first.downcase, input[1..-1] ]
end
def self.prompt_user
printf "enter command > "
inputs = gets.strip.split
end
def self.run
puts "Welcome to the EventReporter"
command = ""
until EXIT_COMMANDS.include?(command)
inputs = prompt_user
if inputs.any?
command, parameters = parse_user_input(inputs)
Command.execute(command, parameters) unless quitting?(command)
else
puts "No command entered."
end
end
puts "Goodbye!"
end
def self.quitting?(command)
EXIT_COMMANDS.include?(command)
end
end
end
EventReporter::CLI.run