]> git.donarmstrong.com Git - lilypond.git/blobdiff - bin/mudela-book.in
release: 0.1.7
[lilypond.git] / bin / mudela-book.in
index 2481b37f1632061ee0880a01934eb76969705d01..374f223a1f4f0c29aecc2ff6b1e13d3dd12a9da4 100644 (file)
@@ -1,8 +1,9 @@
-#!@PERL@ -w
+#!@PERL@ -w            
+# -*-Perl-*-
 my $mudcount = 0;
 my $mudela_b = 0;
-my $outdir = "";
-my $outname = "";
+my $outname = "-";
+my $outdir;
 use Getopt::Long;
 
 sub gen_mufile
@@ -19,7 +20,7 @@ sub close_mudela
 {
     $mudela_b = 0;
     if ($fragment_b) {
-       print MUDELA "}\n \\paper { linewidth = -1.0\\cm; } }\n";
+       print MUDELA "}\n \\paper { linewidth = -1.0\\cm; castingalgorithm = \\Wordwrap; } }\n";
        $fragment_b =0;
     }
     if ( $verbatim_b)  {
@@ -80,14 +81,47 @@ sub parse_mudela_opts
    $fragment_b = 1 if ($s =~ /fragment/ );
 }   
 
-sub main
+sub help
 {
-    GetOptions( 'outdir=s', 'outname=s');
-    $outdir = $opt_outdir;
-    $outname = $opt_outname if (defined ($opt_outname) && $opt_outname);
-    open INFILE, $ARGV[0];
+    print  "usage: convert-mudela [options] [file]
+options: 
+--help
+--outdir=DIRECTORY     write all files in directory DIRECTORY
+--outname=NAME         use NAME as base  for the output
+";
+    exit;
+}
     
-    open BOOK, ">$outdir/$outname";
+sub main
+{
+    GetOptions( 'outdir=s', 'outname=s', 'help');
+    help    if ( $opt_help ) ;
+
+    if  (defined ($opt_outdir)) {
+       $outdir = $opt_outdir .  "/";
+    } else {
+       $outdir = ".";
+    }
+   
+    if (defined ($ARGV[0])) {
+       $infile = $ARGV[0] ;
+    } else {
+       $infile = "-";
+    }
+    if (defined ($opt_outname)) {
+       $outname = $opt_outname ;
+    } else { 
+       die "Need to have an output name, use --outname" if ( $infile eq "-");
+       $outname = "$infile.tex";
+    }
+
+    my $openout ="$outdir$outname"; 
+    if  ( $infile eq $openout ) {
+       die "The input can't be the output\n";
+    }
+
+    open INFILE, "<$infile";
+    open BOOK, ">$openout";
     while (<INFILE>) {
        if ($mudela_b) {
            if (end_b "mudela") {
@@ -117,4 +151,5 @@ sub main
     close BOOK;
 }
 
+
 main;