# File lib/facets/more/command.rb, line 254
 def execute( line=nil )
   case line
   when String
     arguments = Shellwords.shellwords(line)
   when Array
     arguments = line
   else
     arguments = ARGV
   end

   # duplicate arguments to work on them in-place.

   argv = arguments.dup

   # Split single letter option groupings into separate options.
   # ie. -xyz => -x -y -z

   argv = argv.collect { |arg|
     if md = /^-(\w{2,})/.match( arg )
       md[1].split(//).collect { |c| "-#{c}" }
     else
       arg
     end
   }.flatten

   # process global options
   global_options.each do |name|
     o = name.to_s.sub('__','--').sub('_','-')
     m = method(name)
     c = m.arity
     while i = argv.index(o)
       args = argv.slice!(i,c+1)
       args.shift
       m.call(*args)
     end
   end

   # Does this command take subcommands?
   subcommand = !respond_to?(:main)

   # process primary options
   argv = execute_options( argv, subcommand )

   # If this command doesn't take subcommands, then the remaining arguments are arguments for main().
   return send(:main, *argv) unless subcommand

   # What to do if there is nothing else?
   if argv.empty?
     if respond_to?(:default)
       return __send__(:default)
     else
       $stderr << "Nothing to do."
       return
     end
   end

   # Remaining arguments are subcommand and suboptions.

   subcmd = argv.shift.gsub('-','_')
   #puts "subcmd = #{subcmd}"

   # Extend subcommand option module
   subconst = subcmd.gsub(/\W/,'_').capitalize
   #puts self.class.name
   if self.class.const_defined?(subconst)
     puts "Extending self (#{self.class}) with subcommand module #{subconst}" if $debug
     submod = self.class.const_get(subconst)
     self.extend submod
   end

   # process subcommand options
   #puts "Treating the rest of the args as subcommand options:"
   #p argv
   argv = execute_options( argv )

   # This is a little tricky. The method has to be defined by a subclass.
   if self.respond_to?( subcmd ) and not Console::Command.public_instance_methods.include?( subcmd.to_s )
     puts "Calling #{subcmd}(#{argv.inspect})" if $debug
     __send__(subcmd, *argv)
   else
     #begin
       puts "Calling method_missing with #{subcmd}, #{argv.inspect}" if $debug
       method_missing(subcmd, *argv)
     #rescue NoMethodError => e
       #if self.private_methods.include?( "no_command_error" )
       #  no_command_error( *args )
       #else
     #    $stderr << "Non-applicable command -- #{argv.join(' ')}\n"
     #    exit -1
       #end
     #end
   end

#   rescue => err
#     if $DEBUG
#       raise err
#     else
#       msg = err.message.chomp('.') + '.'
#       msg[0,1] = msg[0,1].capitalize
#       msg << " (#{err.class})" if $VERBOSE
#       $stderr << msg
#     end
 end