#!/usr/bin/perl # UCW Gallery -- Master Program # (c) 2012 Martin Mares use strict; use warnings; use Getopt::Long; use FindBin; my $gallery_root = $FindBin::Bin; sub show_help() { print < General options: (none yet) Common commands: scan Scan directory and obtain originals gen Generate web photos from originals cache Rebuild thumbnails and other cached info Other commands: dump-config Show configuration settings dump-meta Show contents of metadata files from-gqview Parse gqview/geeqie collections AMEN exit 0; } Getopt::Long::Configure('require_order'); GetOptions( "help" => \&show_help, "version" => sub { print "UCW Gallery 2.0 (c) 2004-2012 Martin Mares \n"; }, ) or die "Try `gal help' for more information.\n"; Getopt::Long::Configure('default'); @ARGV or die "Missing subcommand.\n"; my $sub = shift @ARGV; $sub =~ /^[0-9a-zA-Z-]+$/ or die "Invalid subcommand $sub\n"; if ($sub eq 'help') { show_help(); } my $sub_path = "$gallery_root/bin/gal-$sub"; -x $sub_path or die "Unknown subcommand $sub\n"; $ENV{"GALLERY_ROOT"} = $gallery_root; $ENV{"PERL5LIB"} = join(":", $gallery_root, $ENV{"PERL5LIB"} // ()); exec $sub_path, @ARGV; die "Cannot execute $sub_path: $!\n";