Sha256: 8645992c3ae1f77b72fa0b6c2718461b24a7108c156935aa8baee6f1356fea98

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

require 'rbkb/cli'

# 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>"

    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_catchall()
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emonti-rbkb-0.6.2 lib/rbkb/cli/b64.rb