lib/kaboom/command.rb in kaboom-0.3.2 vs lib/kaboom/command.rb in kaboom-0.3.3

- old
+ new

@@ -101,17 +101,18 @@ return echo(major,minor) if command == 'echo' || command == 'e' return open(major,minor) if command == 'open' || command == 'o' return random(major) if command == 'random' || command == 'rand' || command == 'r' # if we're operating on a List - if storage.list_exists?(command) - return delete_list(command) if major == 'delete' - return detail_list(command) unless major + list = command + if storage.list_exists?(list) + return delete_list(list) if major == 'delete' + return detail_list(list) unless major unless minor == 'delete' - return add_item(command,major,minor) if minor - return add_item(command,major,stdin.read) if stdin.stat.size > 0 - return search_list_for_item(command, major) + return add_item(list,major,minor) if minor + return add_item(list,major,stdin.read) if stdin.stat.size > 0 + return search_list_for_item(list, major) end end if minor == 'delete' and storage.item_exists?(major) return delete_item(command, major) @@ -155,22 +156,22 @@ end # Public: opens the Item. # # Returns nothing. - def open(major, minor) - if storage.list_exists?(major) - list = List.find(major) - if minor - item = storage.items.detect { |item| item.name == minor } + def open(key, value) + if storage.list_exists?(key) + list = List.find(key) + if value + item = storage.items.detect { |item| item.name == value } output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you." else list.items.each { |item| Platform.open(item) } - output "#{cyan("Boom!")} We just opened all of #{yellow(major)} for you." + output "#{cyan("Boom!")} We just opened all of #{yellow(key)} for you." end else - item = storage.items.detect { |item| item.name == major } + item = storage.items.detect { |item| item.name == key } output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you." end end # Public: Opens a random item @@ -346,40 +347,64 @@ else output "This storage backend does not store #{cyan("Boom!")} data on your computer" end end + def y t + yellow t + end + + def c t + cyan t + end + + def r t + red t + end + # Public: prints all the commands of boom. # # Returns nothing. def help text = %{ - - boom: help --------------------------------------------------- + #{r "BOOM snippets"} ___________________________________________________ - boom display high-level overview - boom all show all items in all lists - boom edit edit the boom JSON file in $EDITOR - boom help this help text - boom storage shows which storage backend you're using - boom switch <storage> switches to a different storage backend + boom display high-level overview + boom #{y "all"} show all items in all lists + boom #{y "edit"} edit the boom JSON file in $EDITOR + boom #{y "help"} this help text + boom #{y "storage"} shows which storage backend you're using + boom #{y "switch"} #{c "<storage>"} switches to a different storage backend - boom <list> create a new list - boom <list> show items for a list - boom <list> delete deletes a list + boom #{c "<list>"} create a new list + boom #{c "<list>"} show items for a list + boom #{c "<list>"} #{y "delete"} deletes a list - boom <list> <name> <value> create a new list item - boom <name> copy item's value to clipboard - boom <list> <name> copy item's value to clipboard - boom open <name> open item's url in browser - boom open <list> <name> open all item's url in browser for a list - boom random open a random item's url in browser - boom random <list> open a random item's url for a list in browser - boom echo <name> echo the item's value without copying - boom echo <list> <name> echo the item's value without copying - boom <list> <name> delete deletes an item + boom #{c "<list> <name> <value>"} create a new list item + boom #{c "<name>"} copy item's value to clipboard + boom #{c "<list> <name>"} copy item's value to clipboard + boom #{y "open"} #{c "<name>"} open item's url in browser + boom #{y "open"} #{c "<list> <name>"} open all item's url in browser for a list + boom #{y "random"} open a random item's url in browser + boom #{y "random"} #{c "<list>"} open a random item's url for a list in browser + boom #{y "echo"} #{c "<name>"} echo the item's value without copying + boom #{y "echo"} #{c "<list> <name>"} echo the item's value without copying + boom #{c "<list> <name>"} #{y "delete"} deletes an item + #{red "KABOOM sharing"} ___________________________________________________ + + boom remote #{y "<any command above>"} using the #{y "~/.boom.remote.conf"} it + kaboom #{y "<any command above>"} connects to an alternative backend + meaning you can pipe to a remote + backend storage + + e.g. to pipe config from a local boom to a remote boom do: + + kaboom #{c("config ackrc")} < boom #{c "config ackrc"} + + ___________________________________________________________________ all other documentation is located at: - https://github.com/holman/boom + https://github.com/markburns/kaboom }.gsub(/^ {8}/, '') # strip the first eight spaces of every line output text end