-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompter.rb
executable file
·65 lines (58 loc) · 1.49 KB
/
prompter.rb
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
module Prompter
def main_menu
puts "Board options: create | show ID | update ID | delete ID\nexit"
print "> "
action, id = gets.chomp.split
[action, id.to_i]
end
def list_menu
puts "List options: create-list | update-list LISTNAME | delete-list LISTNAME"
puts "Card options: create-card | checklist ID | update-card ID | delete-card ID\nback"
print "> "
action, *id_or_list = gets.chomp.split
action.sub!("-", "_") if action.include?("-")
[action, id_or_list.join(" ")]
end
def checklist_menu
puts "Checklist options: add | toggle INDEX | delete INDEX\nback"
print "> "
action, index = gets.chomp.split
[action, index.to_i]
end
def board_form
print "Name: "
name = gets.chomp
print "Description: "
description = gets.chomp
{ name: name, description: description }
end
def checklist_form
print "Title: "
title = gets.chomp
{ title: title, completed: false }
end
def list_form
print "Name: "
name = gets.chomp
{ name: name }
end
def card_form
print "Title: "
title = gets.chomp
print "Members: "
members = gets.chomp.split(", ")
print "Labels: "
labels = gets.chomp.split(", ")
print "Due Date: "
due_date = gets.chomp
{ title: title, members: members, labels: labels, due_date: due_date }
end
def list_selection_form(options)
list = ""
until options.include?(list)
print "Select a list: "
list = gets.chomp
end
list
end
end