fiddle with DB->new parameters
[id3fs.git] / bin / id3fs
index 1998169..547b96d 100755 (executable)
--- a/bin/id3fs
+++ b/bin/id3fs
@@ -12,23 +12,33 @@ $me=($0=~/(?:.*\/)?(.*)/)[0];
 
 my $verbose=0;
 my $help=0;
-my $init=0;
-my @extensions=qw(mp3); # ogg flac);
+my $basedir=undef;
+my $dbpath=undef;
+
+my @extensions=qw(mp3); # ogg flac); # FIXME
 Configure(qw(bundling no_ignore_case));
 my $optret=GetOptions(
-    "verbose|v"  => \$verbose,
-    "quiet|q"    => sub { $verbose=0; },
-    "help|h"     => \$help,
+    "verbose|v"      => \$verbose,
+    "quiet|q"        => sub { $verbose=0; },
+    "help|h"         => \$help,
+    "basedir|d=s"    => \$basedir,
+    "database|db=s"  => \$dbpath,
     "extensions|e=s" => sub { @extensions=split(/\s+|\s*,\s*/, $_[1]); },
-    "init|i"     => \$init,
     );
 
 usage() if(!@ARGV || !$optret || $help);
 
-my $path=shift;
-my $db=ID3FS::DB->new($path, $init, $me);
+if(@ARGV > 1 && !defined($basedir))
+{
+    die("$me: --basedir must be specified if multiple paths are supplied\n");
+}
+
+my $db=ID3FS::DB->new($me, $dbpath, $basedir, $ARGV[0]);
 
-File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path);
+while(my $path=shift)
+{
+    File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path);
+}
 
 sub wanted
 {