#!/usr/bin/env ruby # Liste - reminders, notes, ideas on the go # Daniel Ethridge require "liste" include Liste # 'argv' will be the lowercase version of 'ARGV', this helps for argument matching argv = ARGV.map(&:downcase) help = "\nUsage : `liste` or `liste [arguments]` or `liste .listname \"task\"` or `liste .listname [arguments]` Liste is for those who have short-term memory and those who need constant reminders. You should add the line 'liste login' to your .bashrc When adding an item to a list, the content MUST contain whitespace to be selected, this is accomplished by adding quotes around your list item : `liste .list \"my content has whitespace\"` This is done to prevent the shell from splitting your content into seperate arguments. -------------------------------------------------- \"task to do\" : add 'task' to the todo list .login \"task to do\" : add 'task' to the login list .anylist disp : display the contents of 'anylist' -------------------------------------------------- If you find a bug, want extra features, or have a suggestion, make a branch on github : https://github.com/wlib/liste\n\n" # Just running `liste` (no arguments) will display content of the "todo" list if ARGV.empty? puts "Things to do...\n\n" disp("todo", "number") rescue puts "...nothing here yet"; exit exit end case argv[0] when "?", "h", "help", "-h", "--help" puts help exit # This displays the "login" list when "login" puts "Your tasks...\n\n" disp("login", "bullet") rescue puts "\n...nothing here yet"; exit exit # Calls the edit shortcut when "edit" edit_list() exit end # Parse shell input in the format `liste .listname ["content" / arguments]` if argv[0].start_with?('.') listname = ARGV[0][1..-1] end content = ARGV.select{ |e| e[/\s/] }.join(' ') args = ARGV[1..-1].select{ |e| ! e[/\s/] }.map(&:downcase) # Add content to the todo list, alternatively add to any other list unless content.empty? if ! listname.nil? add(listname, content) rescue newlist(listname, content) exit elsif listname.nil? add("todo", content) rescue newlist("todo", content) exit end end # More than one list argument can be run at a time case # Displays the content in any list when args.include?("disp") puts "Your list '#{listname}'...\n\n" disp("#{listname}", "bullet") rescue puts "\n...nothing here yet"; exit exit end # If nothing is caught then throw an error message puts "Something went wrong, I'm not sure what you want me to do"; exit