Sha256: 73f8ecb6754057687daa6ce09880f2b29193523d7f94fbc26857b04cb386a9ab
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
#!/usr/bin/env ruby # Author Eric Monti (emonti at matasano) # # urlenc converts a string or raw data to a url-encoded string # (url encoding is really just fancy hex encoding) # # Usage: urlenc [options] <data | blank for stdin> # -h, --help Show this message # -v, --version Show version and exit # -f, --file FILENAME Input from FILENAME # -p, --[no-]plus Convert spaces to '+' (default is false) # require 'rbkb' require 'rbkb/command_line' include RBkB::CommandLine #------------------------------------------------------------------------------ # Init options and arg parsing OPTS = {} arg = bkb_stdargs(nil, OPTS) arg = bkb_inputargs(arg, OPTS) arg.banner += " <data | blank for stdin>" arg.on("-p", "--[no-]plus", "Convert spaces to '+' (default is false)") do |p| OPTS[:plus] = p end #------------------------------------------------------------------------------ # Add local options here #------------------------------------------------------------------------------ # Parse arguments arg.parse!(ARGV) rescue bail "Error: #{$!}\nUse -h|--help for more info." # default string arg if OPTS[:indat].nil? and a=ARGV.shift OPTS[:indat] = a.dup end # catchall if ARGV.length != 0 bail "Error: bad arguments - #{ARGV.join(' ')}\n-h|--help for more info." end # Default to standard input OPTS[:indat] ||= STDIN.read() #------------------------------------------------------------------------------ # Do stuff puts OPTS[:indat].urlenc(:plus => OPTS[:plus])
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
emonti-rbkb-0.6.1.1 | bin/urlenc |
emonti-rbkb-0.6.1.2 | bin/urlenc |
emonti-rbkb-0.6.1.3 | bin/urlenc |