Class: Migr8::Actions::HistAction

Inherits:
Action
  • Object
show all
Defined in:
lib/migr8.rb

Constant Summary collapse

NAME =
"hist"
DESC =
"list history of versions"
OPTS =
["-o: open history file with $MIGR8_EDITOR",
"-b: rebuild history file from migration files"]
ARGS =
nil

Instance Method Summary collapse

Methods inherited from Action

#cmdopterr, find_by_name, #get_command, inherited, #parse, #parser, #repository, #short_usage, subclasses, #usage

Instance Method Details

#run(options, args) ⇒ Object



1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
# File 'lib/migr8.rb', line 1507

def run(options, args)
  open_p  = options['o']
  build_p = options['b']
  #
  if open_p
    editor = ENV['MIGR8_EDITOR']
    if ! editor || editor.empty?
      $stderr << "ERROR: $MIGR8_EDITOR is not set.\n"
      raise cmdopterr("#{NAME}: failed to open history file.")
    end
    histfile = repository().history_filepath()
    puts "$ #{editor} #{histfile}"
    system("#{editor} #{histfile}")
    return
  end
  #
  if build_p
    repo = repository()
    puts "## rebulding '#{repo.history_filepath()}' ..."
    repo.rebuild_history_file()
    puts "## done."
    return
  end
  #
  op = RepositoryOperation.new(repository())
  puts op.history
end