mirror of https://github.com/Calamitous/iris.git
Add a pop function to display and mark read all unread messages in the corpus
This commit is contained in:
parent
ce84f6ed10
commit
95e77eb1b1
33
iris.rb
33
iris.rb
|
@ -17,10 +17,11 @@ class Config
|
||||||
HOSTNAME = `hostname -d`.chomp
|
HOSTNAME = `hostname -d`.chomp
|
||||||
AUTHOR = "#{USER}@#{HOSTNAME}"
|
AUTHOR = "#{USER}@#{HOSTNAME}"
|
||||||
OPTIONS = %w[
|
OPTIONS = %w[
|
||||||
--dump
|
|
||||||
--debug
|
--debug
|
||||||
|
--dump
|
||||||
--help
|
--help
|
||||||
--interactive
|
--interactive
|
||||||
|
--pop
|
||||||
--stats
|
--stats
|
||||||
--test-file
|
--test-file
|
||||||
--version
|
--version
|
||||||
|
@ -28,11 +29,12 @@ class Config
|
||||||
-f
|
-f
|
||||||
-h
|
-h
|
||||||
-i
|
-i
|
||||||
|
-p
|
||||||
-s
|
-s
|
||||||
-v
|
-v
|
||||||
]
|
]
|
||||||
INTERACTIVE_OPTIONS = %w[-i --interactive]
|
INTERACTIVE_OPTIONS = %w[-i --interactive]
|
||||||
NONINTERACTIVE_OPTIONS = %w[-d --dump -h --help -v --version -s --stats]
|
NONINTERACTIVE_OPTIONS = %w[-d --dump -h --help -v --version -s --stats -p --pop]
|
||||||
NONFILE_OPTIONS = %w[-h --help -v --version]
|
NONFILE_OPTIONS = %w[-h --help -v --version]
|
||||||
|
|
||||||
@@debug_mode = false
|
@@debug_mode = false
|
||||||
|
@ -643,7 +645,7 @@ class Display
|
||||||
end
|
end
|
||||||
|
|
||||||
class Interface
|
class Interface
|
||||||
ONE_SHOTS = %w{help topics unread compose quit freshen reset_display reply edit delete mark_read info}
|
ONE_SHOTS = %w{help topics unread compose quit freshen reset_display reply edit delete mark_read info pop}
|
||||||
CMD_MAP = {
|
CMD_MAP = {
|
||||||
't' => 'topics',
|
't' => 'topics',
|
||||||
'topics' => 'topics',
|
'topics' => 'topics',
|
||||||
|
@ -671,6 +673,8 @@ class Interface
|
||||||
'clear' => 'reset_display',
|
'clear' => 'reset_display',
|
||||||
'i' => 'info',
|
'i' => 'info',
|
||||||
'info ' => 'info',
|
'info ' => 'info',
|
||||||
|
'p' => 'pop',
|
||||||
|
'pop' => 'pop',
|
||||||
}
|
}
|
||||||
|
|
||||||
def browsing_handler(line)
|
def browsing_handler(line)
|
||||||
|
@ -713,6 +717,22 @@ class Interface
|
||||||
Display.say
|
Display.say
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.pop
|
||||||
|
unread_messages = Corpus.unread_messages
|
||||||
|
unread_messages.each { |message|
|
||||||
|
Display.say message.to_display
|
||||||
|
new_reads = (Corpus.read_hashes + [message.hash] + message.replies.map(&:hash)).uniq.sort
|
||||||
|
IrisFile.write_read_file(new_reads.to_json)
|
||||||
|
Corpus.load
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def pop
|
||||||
|
Display.say
|
||||||
|
Interface.pop
|
||||||
|
Display.say
|
||||||
|
end
|
||||||
|
|
||||||
def compose
|
def compose
|
||||||
@mode = :composing
|
@mode = :composing
|
||||||
@text_buffer = ''
|
@text_buffer = ''
|
||||||
|
@ -987,6 +1007,7 @@ class Interface
|
||||||
'freshen, f - Reload to get any new messages',
|
'freshen, f - Reload to get any new messages',
|
||||||
'reset, clear - Fix screen in case of text corruption',
|
'reset, clear - Fix screen in case of text corruption',
|
||||||
'info, i - Display Iris version and message stats',
|
'info, i - Display Iris version and message stats',
|
||||||
|
'pop, p - Pop unread messages',
|
||||||
'quit, q - Quit Iris',
|
'quit, q - Quit Iris',
|
||||||
'',
|
'',
|
||||||
'Full documentation available here:',
|
'Full documentation available here:',
|
||||||
|
@ -1033,6 +1054,7 @@ class CLI
|
||||||
'--help, -h - Display this text.',
|
'--help, -h - Display this text.',
|
||||||
'--version, -v - Display the current version of Iris.',
|
'--version, -v - Display the current version of Iris.',
|
||||||
'--stats, -s - Display Iris version and message stats.',
|
'--stats, -s - Display Iris version and message stats.',
|
||||||
|
'--pop, -p - Pop unread messages.',
|
||||||
'--interactive, -i - Enter interactive mode (default)',
|
'--interactive, -i - Enter interactive mode (default)',
|
||||||
'--dump, -d - Dump entire message corpus out.',
|
'--dump, -d - Dump entire message corpus out.',
|
||||||
'--test-file <filename>, -f <filename> - Use the specified test file for messages.',
|
'--test-file <filename>, -f <filename> - Use the specified test file for messages.',
|
||||||
|
@ -1063,6 +1085,11 @@ class CLI
|
||||||
exit(0)
|
exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (args & %w{-p --pop}).any?
|
||||||
|
Interface.pop
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
Display.say "Unrecognized option(s) #{args.join(', ')}"
|
Display.say "Unrecognized option(s) #{args.join(', ')}"
|
||||||
Display.say "Try -h for help"
|
Display.say "Try -h for help"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue