Sha256: d5b2e07d2bf1d8c1ca88ba44419b22f8af131ec56fff6bc940ca346c124a5dcc

Contents?: true

Size: 779 Bytes

Versions: 11

Compression:

Stored size: 779 Bytes

Contents

require 'rbkb/cli'

# Copyright 2009 emonti at matasano.com 
# See README.rdoc for license information
#
# b64 converts strings or raw data to base-64 encoding.
class Rbkb::Cli::B64 < Rbkb::Cli::Executable
  def make_parser
    super()
    arg = @oparse
    arg.banner += " <data | blank for stdin>"

    add_std_file_opt(:indat)

    arg.on("-l", "--length LEN", Numeric, "Output LEN chars per line") do |l|
        bail("length must be > 0") unless l > 0
        @opts[:len] = l
    end
  end

  def parse(*args)
    super(*args)
    parse_string_argument(:indat)
    parse_file_argument(:indat)
    parse_catchall()
    @opts[:indat] ||= @stdin.read
  end

  def go(*args)
    super(*args)
    @stdout << @opts[:indat].b64(opts[:len]).chomp + "\n"
    self.exit(0)
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
emonti-rbkb-0.6.6 lib/rbkb/cli/b64.rb
emonti-rbkb-0.6.7 lib/rbkb/cli/b64.rb
emonti-rbkb-0.6.8 lib/rbkb/cli/b64.rb
emonti-rbkb-0.6.9.1 lib/rbkb/cli/b64.rb
emonti-rbkb-0.6.9 lib/rbkb/cli/b64.rb
rbkb-0.7.2 lib/rbkb/cli/b64.rb
rbkb-0.7.1 lib/rbkb/cli/b64.rb
rbkb-0.7.0 lib/rbkb/cli/b64.rb
rbkb-0.6.12 lib/rbkb/cli/b64.rb
rbkb-0.6.11 lib/rbkb/cli/b64.rb
rbkb-0.6.10 lib/rbkb/cli/b64.rb