Sha256: 475ba3af89fb0eb345e13691a6b3d00b1c0cee9ed1329d164b6bdd7a8bf3331a

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
require_relative '../command'
require_relative '../eval'
class Trepan::Command::PsCommand < Trepan::Command

  unless defined?(HELP)
    NAME = File.basename(__FILE__, '.rb')
    HELP = <<-HELP
**#{NAME}* *Ruby-array*

Print the value of the *array* in columns and sorted.
    HELP

    CATEGORY      = 'data'
    MIN_ARGS      = 1  # Need least this many
    SHORT_HELP    = 'Print array sorted and in columns'
  end

  def run(args)
    array = @proc.debug_eval(@proc.cmd_argstr, @proc.settings[:maxstring])
    # FIXME: should test for enumerable
    if array.is_a?(Array)
      msg columnize_commands(array.sort)
    else
      errmsg "ps: #{@proc.cmd_argstr} should evaluate an Array not #{array.class}"
    end
  end
end

if __FILE__ == $0
  require_relative '../mock'
  dbgr, cmd = MockDebugger::setup
  arg_str = '(1..30).to_a'
  cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
  cmd.run([cmd.name, arg_str])
  arg_str = '1'
  cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
  cmd.run([cmd.name, arg_str])
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trepanning-2.15.35 processor/command/ps.rb
trepanning-1.93.35 processor/command/ps.rb
trepanning-2.15.33 processor/command/ps.rb
trepanning-1.93.32 processor/command/ps.rb