#!/usr/bin/perl

# $Id: dvdrip,v 1.12 2002/09/15 15:37:18 joern Exp $

#-----------------------------------------------------------------------
# Copyright (C) 2001-2002 Jrn Reder <joern@zyn.de> All Rights Reserved
# 
# This program is part of Video::DVDRip, which is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#-----------------------------------------------------------------------

package Video::DVDRip;

use strict;
use lib 'lib';
use Getopt::Std;

# That's Perl! The job classes derive from this class,
# which is decided at *runtime* - this way standard and
# cluster mode can share the same job execution system
# by inserting the cluster logic dynamically into the
# inheritence line... great stuff!

BEGIN {	$Video::DVDRip::JobClass = "Video::DVDRip::Job" }

use Video::DVDRip;
use Video::DVDRip::GUI::Main;

my $USAGE = <<'_USAGE';

usage: dvdrip [-c] [-d level] [filename]
       dvdrip --version | -version | -v

       -c open cluster control window
       -d set debugging level

_USAGE

main: {
	if ( $ARGV[0] =~ /^-(v|-?version)$/ ) {
		print $Video::DVDRip::VERSION,"\n";
		exit 0;
	}

	# get options
	my %opt;
	my $opt_ok = getopts ('cd:', \%opt);
	usage() if not $opt_ok;

	# fetch filename paramter
	my $filename = shift @ARGV;

	# no more args allowed
	usage() if @ARGV;

	# set requested debugging level
	Video::DVDRip::GUI::Main->set_debug_level( $opt{d} || 0 );

	# create GUI object
	my $gui = Video::DVDRip::GUI::Main->new;

	# start GUI
	$gui->start (
		filename	     => $filename,
		open_cluster_control => $opt{c}
	);


	END { Gtk->exit(0) }
}

sub usage {
	print $USAGE;
	exit 1;
}
