Sha256: 59a71407fc986d546702ff5525b8209f195257a6104122a00dee32971ef8a7f2

Contents?: true

Size: 1.72 KB

Versions: 12

Compression:

Stored size: 1.72 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
require_relative '../../base/subsubcmd'
require_relative '../substitute'

class Trepan::SubSubcommand::SetSubstitutePath < Trepan::SubSubcommand
  unless defined?(HELP)
    HELP         = 
'Add a substitution rule replacing FROM into TO in source file names.
If a substitution rule was previously set for FROM, the old rule
is replaced by the new one.'
    MIN_ABBREV   = 'fi'.size  
    MAX_ARGS     = 2
    NAME         = File.basename(__FILE__, '.rb')
    SHORT_HELP   = 'Use PATH in place of an filename'
    PREFIX       = %w(set substitute path)
  end

  def run(args)
    if args.size != 3
      errmsg "This command needs 2 arguments, got #{args.size-1}."
      return
    end
    from_path = args[1]
    to_path   = args[2]
    # FIXME Check from_path name to see if it is loaded
    if File.exist?(to_path)
      LineCache::remap_file(from_path, to_path)
    else
      errmsg "File #{to_path} doesn't exist"
    end
  end
end

if __FILE__ == $0
  # Demo it.
  require_relative '../../../mock'
  require_relative '../../../subcmd'
  name = File.basename(__FILE__, '.rb')

  # FIXME: DRY the below code
  dbgr, set_cmd = MockDebugger::setup('set')
  testcmdMgr = Trepan::Subcmd.new(set_cmd)
  cmd_name   = Trepan::SubSubcommand::SetSubstitutePath::PREFIX.join('')
  setx_cmd   = Trepan::SubSubcommand::SetSubstitutePath.new(set_cmd.proc, 
                                                            set_cmd,
                                                            cmd_name)
  # require_relative '../../../../lib/trepanning'
  # dbgr = Trepan.new
  # dbgr.debugger
  setx_cmd.run([])

  # name = File.basename(__FILE__, '.rb')
  # subcommand.summary_help(name)
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
trepanning-2.15.35 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-1.93.35 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-2.15.33 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-1.93.32 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.1.6 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.1.4 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.1.3 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.1.2 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.1.1 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.1.0 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.0.9 processor/command/set_subcmd/substitute_subcmd/path.rb
trepanning-0.0.8 processor/command/set_subcmd/substitute_subcmd/path.rb