]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
Emit warnings for missing translations.
[lilypond.git] / lily / main.cc
index d0d21601ec500bb94d5e8a7f7a733f1accc39e94..d4016e21f7e38bafa1fbafab1f98e5993030046b 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -55,43 +55,6 @@ using namespace std;
 #include "version.hh"
 #include "warn.hh"
 
-/*
- * Global options that can be overridden through command line.
- */
-
-/* Names of header fields to be dumped to a separate file. */
-vector<string> dump_header_fieldnames_global;
-
-/* Name of initialisation file. */
-string init_name_global;
-
-/* Output formats to generate.  */
-string output_format_global = "";
-
-/* Current output name. */
-string output_name_global;
-
-/* Run in safe mode? */
-bool be_safe_global = false;
-
-/* Provide URI links to the original file */
-bool point_and_click_global = true;
-
-/* Verbose progress indication? */
-bool be_verbose_global = false;
-
-/* Scheme code to execute before parsing, after .scm init.
-   This is where -e arguments are appended to.  */
-string init_scheme_code_global;
-string init_scheme_variables_global;
-
-bool relocate_binary = true;
-
-/*
- * Miscellaneous global stuff.
- */
-File_path global_path;
-
 /*
  * File globals.
  */
@@ -125,13 +88,8 @@ static char const *WARRANTY
         "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
         "Boston, MA 02111-1307, USA.\n");
 
-/* Where the init files live.  Typically:
-   LILYPOND_DATADIR = /usr/share/lilypond
-*/
-string lilypond_datadir;
-
 /* The jail specification: USER, GROUP, JAIL, DIR. */
-string jail_spec;
+static string jail_spec;
 
 /*  The option parser */
 static Getopt_long *option_parser = 0;
@@ -169,10 +127,16 @@ static Long_option_init options_static[]
     "and cd into DIR")
   },
 #endif
+  {
+    _i ("LOGLEVEL"), "loglevel", 'l', _i ("print log messages according to"
+    " LOGLEVEL.  Possible values are:\n"
+    "NONE, ERROR, WARNING, BASIC, PROGRESS, INFO (default) and DEBUG.")
+  },
   {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")},
   {0, "relocate", 0, _i ("relocate using directory of lilypond program")},
+  {0, "silent", 's', _i ("no progress, only error messages (equivalent to loglevel=ERROR)")},
   {0, "version", 'v', _i ("show version number and exit")},
-  {0, "verbose", 'V', _i ("be verbose")},
+  {0, "verbose", 'V', _i ("be verbose (equivalent to loglevel=DEBUG)")},
   {0, "warranty", 'w', _i ("show warranty and copyright")},
   {0, 0, 0, 0}
 };
@@ -239,7 +203,7 @@ static void
 copyright ()
 {
   /* Do not update the copyright years here, run `make grand-replace'  */
-  printf ("%s", (_f ("Copyright (c) %s by\n%s  and others.", "1996--2011",
+  printf ("%s", (_f ("Copyright (c) %s by\n%s  and others.", "1996--2012",
                      AUTHORS).c_str ()));
   printf ("\n");
 }
@@ -404,7 +368,7 @@ main_with_guile (void *, int, char **)
   prepend_load_path (lilypond_datadir);
   prepend_load_path (lilypond_datadir + "/scm");
 
-  if (be_verbose_global)
+  if (is_loglevel (LOG_DEBUG))
     dir_info (stderr);
 
   init_scheme_variables_global = "(list " + init_scheme_variables_global + ")";
@@ -556,7 +520,13 @@ parse_argv (int argc, char **argv)
           show_help = true;
           break;
         case 'V':
-          be_verbose_global = true;
+          set_loglevel (LOGLEVEL_DEBUG);
+          break;
+        case 's':
+          set_loglevel (LOGLEVEL_ERROR);
+          break;
+        case 'l':
+          set_loglevel (option_parser->optional_argument_str0_);
           break;
         default:
           programming_error (to_string ("unhandled short option: %c",
@@ -572,7 +542,7 @@ parse_argv (int argc, char **argv)
   if (show_help)
     {
       ly_usage ();
-      if (be_verbose_global)
+      if (is_loglevel (LOG_DEBUG))
         dir_info (stdout);
       exit (0);
     }
@@ -599,8 +569,6 @@ setup_guile_env ()
                "104857600", overwrite);
 }
 
-vector<string> start_environment_global;
-
 int
 main (int argc, char **argv, char **envp)
 {
@@ -610,11 +578,13 @@ main (int argc, char **argv, char **envp)
     start_environment_global.push_back (*p);
 
   if (getenv ("LILYPOND_VERBOSE"))
-    be_verbose_global = true;
+    set_loglevel (LOGLEVEL_DEBUG);
+  if (getenv ("LILYPOND_LOGLEVEL"))
+    set_loglevel (getenv ("LILYPOND_LOGLEVEL"));
 
   setup_localisation ();
   parse_argv (argc, argv);
-  if (isatty (STDIN_FILENO))
+  if (isatty (STDIN_FILENO) && (is_loglevel (LOG_BASIC)))
     identify (stderr);
 
   setup_paths (argv[0]);