Sha256: e4947a21626420cc274fb69cddfd34f4a73108c3a0dc46bb57bb373303b294ae

Contents?: true

Size: 485 Bytes

Versions: 6

Compression:

Stored size: 485 Bytes

Contents

class Cl
  class Help
    class Usage < Struct.new(:ctx, :cmd)
      def format
        cmd.registry_keys.map do |key|
          line(key)
        end
      end

      def line(key)
        usage = [executable, key.to_s.gsub(':', ' ')]
        usage += cmd.args.map(&:to_s) # { |arg| "[#{arg}]" }
        usage << '[options]' if opts?
        usage.join(' ')
      end

      def executable
        ctx.name
      end

      def opts?
        cmd.opts.any?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
travis-cl-1.2.4 lib/cl/help/usage.rb
cl-1.2.4 lib/cl/help/usage.rb
cl-1.2.3 lib/cl/help/usage.rb
cl-1.2.2 lib/cl/help/usage.rb
cl-1.2.1 lib/cl/help/usage.rb
cl-1.2.0 lib/cl/help/usage.rb