# Ian Beckwith <ianb@erislabs.net>
#
+use lib '/home/ianb/projects/id3fs/id3fs/lib';
use strict;
+use Getopt::Long qw(Configure);
+use ID3FS::DB;
+use ID3FS::Fuse;
use vars qw($me);
$me=($0=~/(?:.*\/)?(.*)/)[0];
+our $VERSION="1.00";
my $verbose=0;
-my $doneargs=0;
-my $donesomething=0;
+my $help=0;
+my $dbpath=undef;
+my $tagdepth=undef;
-while($_=shift)
-{
- if(/^-/ && !$doneargs)
- {
- if (/-v/) { $verbose=1; }
- elsif(/-q/) { $verbose=0; }
- elsif(/--/) { $doneargs=1; }
- elsif(/-h/) { usage(); }
- else { usage(); }
- next;
- }
- $donesomething=1;
- my $file=$_;
-}
+Configure(qw(bundling no_ignore_case));
+my $optret=GetOptions(
+ "verbose|v" => sub { $verbose++; },
+ "help|h" => \$help,
+ "database|f=s" => \$dbpath,
+ "t|tagdepth=s" => \$tagdepth,
+ );
-unless($donesomething)
-{
- usage();
-}
+usage() if(scalar(@ARGV) != 2 || !$optret || $help);
+my $source=shift;
+my $mountpoint=shift;
+
+my $db=ID3FS::DB->new($me, $verbose, 0, $dbpath, $source);
+exit unless($db);
+
+my $fuse=ID3FS::Fuse->new($db, $source, $mountpoint, $verbose, $tagdepth);
+$fuse->run();
sub usage
{
- die("Usage: $me [-v] [-q] [-h] [--] file...\n".
- " -v\tVerbose\n".
- " -q\tQuiet (default)\n".
- " -h\tThis help\n".
- " --\tEnd of options\n");
+ die("Usage: $me [-vqh] [-f <dbfile>] [--] <sourcedir> <mountpoint>\n".
+ " -v\t\t\tVerbose (repeat for more verbosity)\n".
+ " -h\t\t\tThis help\n".
+ " -f|--database=FILE\tPath to database file\n" .
+ " --\t\t\tEnd of options\n");
}
__END__
-
=head1 NAME
-program - description
+id3fsd - FUSE filesystem for browsing id3 tags
=head1 SYNOPSIS
-B<> [I<-v>] [I<-q>] [I<-h>] [I<file>...]
+B<id3fsd> [B<-vh>] S<B<[-f >I<dbfile>]> [B<-->] I<SOURCEDIR> I<MOUNTPOINT>
=head1 DESCRIPTION
+id3fsd provides a browsable filesystem of your music files, organised
+into sub-directories by id3 tags (or flac/ogg comments).
+
+An index should first be created with L<id3fs-index(1)>, then id3fsd
+can mount the files in I<SOURCEDIR> on the directory I<MOUNTPOINT>.
+
+If not explicitly specified (with B<-f>), the index is searched for
+at I<SOURCEDIR>/B<.id3fs>.
+
+The resulting filesystem is read-only. Tags appear as directories,
+and files appear as symlinks to the actual files in I<SOURCEDIR>.
+
+FIXME: better description, allow_others/fuse.conf, fstab, explain genre tag
+
=head1 OPTIONS
=over 4
=item B<-v>
-Enable verbose operation.
-
-=item B<-q>
-
-Quiet (no output). This is the default.
+Enable verbose operation. Repeat for more verbosity.
=item B<-h>
Show a short help message.
+=item S<B<-f >I<FILE>> | S<B<--database=>I<FILE>>
+
+Use database in I<FILE>. The default is I<SOURCEDIR>/B<.id3fs>.
+
=item B<-->
End of options.
=back
-=head1 FILES
+=head1 EXAMPLES
+
+To mount an id3fs filesystem which indexes B<~/music/albums> on
+B<~/music/tags>:
+
+First create the index:
+
+ id3fs-index -v ~/music/albums
-=head1 ENVIRONMENT
+If you have a large collection of music, this may take some time.
-=head1 DIAGNOSTICS
+Then create the mountpoint:
+
+ mkdir ~/music/tags
+
+and mount the filesystem:
+
+ id3fsd ~/music/albums ~/music/tags
+
+Then explore the tags in ~/music/tags/
+
+FIXME: fstab
=head1 BUGS
-None known. Please report any found to ianb@erislabs.net
+Please report any found to ianb@erislabs.net
=head1 SEE ALSO
+L<id3fs-index(1)>, L<http://fuse.sourceforge.net>
+
=head1 AUTHOR
Ian Beckwith <ianb@erislabs.net>
The latest version can be found at:
-B<http://erislabs.net/ianb/projects//>
+B<http://erislabs.net/ianb/projects/id3fs/>
=head1 COPYRIGHT
-Copyright 2008 Ian Beckwith <ianb@erislabs.net>
+Copyright 2010 Ian Beckwith <ianb@erislabs.net>
-This program is free software; you can redistribute it and/or modify
+This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or (at
-your option) any later version.
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+along with this program. If not, see <http://www.gnu.org/licenses/>.
=cut