adding cli_display.rb as main way to sort through a resultset
[zcc.git] / lib / zcc / cli_display.rb
blobe58c10f943c51a09aa9c26f22a278d441835b494
1 #!/usr/local/bin/ruby -w
3 require "rubygems"
4 require "highline/import"
6 #ADD IN OVERWRITE????
9 clear = %x{clear}
10 #print clear
11 a = [1,2,3,4]
12 say("\nYou can even build shells...")
14 # Help statements:
16 help_n = "Next Z39.50 server/group of zservers.\n>  n"
18 help_num = "View that record by typing in the index number\n> 16." # this represents the '#'
20 help_p = "Pick the record at that index position into the result set to work on and save."
22 help_s = "Select sort. Hit 's' to get a menu of sort possibilities. Possible sorts will include: relevancy, title, author, date, date_fixed, subfield (in form of 245a)...\n>  s5"
24 #help_v = "View the record. Shows the full MARC record."
26 help_r = "Remove the record from the result set. This is a way to narrow the result set.\n> r4\nRemoves record 4 from the result set."
28 help_c = "Compare two records. Compares the records line by line. Lines with an 'm' match each other. Lines with a plus sign are in the first record but not the second. Lines with a minus sign '-'"
30 help_l = "Lint the record."
32 help_d = "Done selecting records. If at least one record has been selected you continue on. If no records have been selected you are presented with a search prompt again."
34 help_f = "Forwards through the result set"
35 help_b = "backwards through the result set"
36 help_all = "Select all the records in the result set to work on and save."
40 take_how_many = 'multi' #'one' # 'multi'
42 loop do
43   choose do |menu|
44     #print clear
45     menu.layout = :one_line
46     menu.readline = true
47     menu.shell  = true
48     menu.prompt = "Enter "
49     menu.select_by = :name
50     
51     # #
52     menu.choice('#', help_num) do |command, details|
53       say(help_num)
54     end
55     for x in a
56       menu.hidden(:"#{x}") {|cmd, details| puts cmd}
57     end
58     
59     # n
60     unless take_how_many == 'one'
61     menu.choice(:n, "Go to the next Z39.50 server.") do |command, details|
62       say("next:  #{details}...")
63     end
64     end
65     # s
66     menu.choice('s#', help_s) do |command, details|
67       ask("Which record number do you want?")
68     end
69     menu.hidden(:s, help_s){|c,d| puts help_s}
70     for x in a
71       menu.hidden(:"s#{x}") {|cmd, details| puts cmd}
72     end
73     
74     # c
75     menu.choice('c#-#', help_c) do |command, details|
76       say(help_c)
77     end
78     ###redo this one!
79     #for x in 1..5
80     #   for y in 1..5
81     #     possibilities << "cx-y" unless y == x
82     #   end
83     #end
84     for x in a
85       menu.hidden(:"c#{x}") {|cmd, details| puts cmd}
86     end
87     
88     # l
89     menu.choice('l#', help_l) do |command, details|
90       say(help_l)
91       ask("Which record do you want to lint? ")
92     end
93     for x in a
94       menu.hidden(:"l#{x}") {|cmd, details| puts cmd}
95     end
96     
97     # d
98     unless take_how_many == 'one'
99     menu.choice(:d, "Lint.") do |command, details|
100       say("Saving file with options:  #{details}...")
101     end
102     end
103     
104     # none -- only for final record taking
105     
106     
107     menu.choice(:quit, "Exit program.") { exit }
108     
109   end
110