lib/bunch/bunchCLI.rb in bunchcli-1.1.2 vs lib/bunch/bunchCLI.rb in bunchcli-1.1.3
- old
+ new
@@ -91,10 +91,12 @@
%(x-bunch://raw?file=#{bunch}#{params})
elsif url_method == 'raw'
%(x-bunch://raw?txt=#{bunch}#{params})
elsif url_method == 'snippet'
%(x-bunch://snippet?file=#{bunch}#{params})
+ elsif url_method == 'setPref'
+ %(x-bunch://setPref?#{bunch})
else
%(x-bunch://#{url_method}?bunch=#{bunch[:title]}#{params})
end
end
@@ -122,10 +124,22 @@
def human_action
(url_method.gsub(/e$/, '') + 'ing').capitalize
end
+ def list_preferences
+ prefs =<<EOF
+toggleBunches=[0,1] Allow Bunches to be both opened and closed
+configDir=[path] Absolute path to Bunches folder
+singleBunchMode=[0,1] Close open Bunch when opening new one
+preserveOpenBunches=[0,1] Restore Open Bunches on Launch
+debugLevel=[0-4] Set the logging level for the Bunch Log
+EOF
+ puts prefs
+ end
+
+
def open(str)
# get front app
front_app = %x{osascript -e 'tell application "System Events" to return name of first application process whose frontmost is true'}.strip
bid = bundle_id(front_app)
@success = bid if (bid)
@@ -146,9 +160,22 @@
if @show_url
$stdout.puts _url
else
warn "Opening snippet"
`open '#{_url}'`
+ end
+ elsif @url_method == 'setPref'
+ if str =~ /^(\w+)=([^= ]+)$/
+ _url = url(str)
+ if @show_url
+ $stdout.puts _url
+ else
+ warn "Setting preference #{str}"
+ `open '#{_url}'`
+ end
+ else
+ warn "Invalid key=value pair"
+ Process.exit 1
end
else
bunch = find_bunch(str)
unless bunch
if File.exists?(str)