#!/usr/bin/ruby.ruby3.4 
#
# == Synopsis
#
# Destroys the files for leaves, seasons, and other objects of the Autumn
# framework.
#
# == Usage
#
# script/destroy <options> <object> <name>
#
# <object>:: The object type to destroy. Valid types are "leaf" and "season".
# <name>:: The name of the object to destroy. For example, you can call
#          "script/destroy leaf Scorekeeper" to remove a leaf named Scorekeeper.
#
# == Options
#
# --help, -h:: Displays this usage information.
# --vcs, -c:: Remove any created files or directories from the project's version
#             control system. (Autodetects CVS and Subversion.)

require 'libs/script'

opts = GetoptLong.new(
  [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
  [ '--vcs', '-c', GetoptLong::NO_ARGUMENT ]
)

script = Autumn::Script.new

begin
  opts.each do |opt, arg|
    case opt
      when '--help' then RDoc::usage
      when '--vcs' then script.use_vcs
    end
  end
rescue GetoptLong::InvalidOption
  RDoc::usage
  exit 0
end

exit(0) unless script.parse_argv(ARGV)

case script.object
  when 'leaf' then script.call_generator(:unleaf)
  when 'season' then script.call_generator(:unseason)
end
