bin/pinpress in pinpress-1.5.2 vs bin/pinpress in pinpress-1.6.0

- old
+ new

@@ -30,14 +30,17 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. #-------------------------------------------------------------------- require 'chronic' require 'cliutils' +require 'digest/md5' require 'gli' require 'htmlentities' +require 'pbcopy' require 'pinboard' require 'pinpress' +require 'uri' include CLIUtils::Configuration include CLIUtils::Messaging include GLI::App @@ -133,10 +136,14 @@ c.flag([:m], desc: 'The pin template to use') c.flag([:n], desc: 'The number of results to return') c.flag([:s], desc: 'The start date to pull pins from') c.flag([:t], desc: 'The tags to use (e.g., "ruby,pinboard")') + c.switch([:a], desc: 'Auto-links any URLs found in a pin description') + c.switch([:c], desc: 'Copy final output to the system clipboard') + c.switch([:l], desc: 'Allows the user to create <a> links around detected URLs') + c.desc 'Gets pins from Pinboard' c.action do |global_options, options, args| PinPress.verbose = global_options[:v] # Figure out the template to use based on the passed argument (if any) @@ -150,12 +157,22 @@ opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s] opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN)) # Request pin data from Pinboard and output the return data. output = PinPress.pin_yield(template, opts) - puts output if output + # If the `-c` switch is used, copy the output to the system clipboard; + # otherwise, simply output it to the termianl. + # puts output if output + if output + if options[:c] + output | pbcopy + else + puts output + end + end + # Save the last-run date to the configuration file. configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0].last_run = Time.now.utc.iso8601 configuration.save end @@ -179,12 +196,22 @@ # Set our common options. opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN)) # Request pin data from Pinboard and output the return data. output = PinPress.pin_yield(template, opts) - puts output if output + # If the `-c` switch is used, copy the output to the system clipboard; + # otherwise, simply output it to the termianl. + # puts output if output + if output + if options[:c] + output | pbcopy + else + puts output + end + end + # Save the last-run date to the configuration file. configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0].last_run = Time.now.utc.iso8601 configuration.save end end @@ -217,12 +244,22 @@ opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s] opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN)) # Request tag data from Pinboard and output the return data. output = PinPress.tag_yield(template, opts) - puts output if output + # If the `-c` switch is used, copy the output to the system clipboard; + # otherwise, simply output it to the termianl. + # puts output if output + if output + if options[:c] + output | pbcopy + else + puts output + end + end + # Save the last-run date to the configuration file. t_config = configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0] t_config.last_run = Time.now.utc.iso8601 configuration.save end @@ -247,10 +284,20 @@ # Set our common options. opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN)) # Request tag data from Pinboard and output the return data. output = PinPress.tag_yield(template, opts) - puts output if output + + # If the `-c` switch is used, copy the output to the system clipboard; + # otherwise, simply output it to the termianl. + # puts output if output + if output + if options[:c] + output | pbcopy + else + puts output + end + end # Save the last-run date to the configuration file. t_config = configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0] t_config.last_run = Time.now.utc.iso8601 configuration.save