Sfoglia il codice sorgente

Move EXA_DEBUG variable to vars file

Benjamin Sago 8 anni fa
parent
commit
e154b58268
3 ha cambiato i file con 12 aggiunte e 2 eliminazioni
  1. 6 2
      src/bin/main.rs
  2. 1 0
      src/exa.rs
  3. 5 0
      src/options/vars.rs

+ 6 - 2
src/bin/main.rs

@@ -48,12 +48,16 @@ fn main() {
 
 /// Sets up a global logger if one is asked for.
 /// The ‘EXA_DEBUG’ environment variable controls whether log messages are
-/// displayed or not. Currently there are just two settings (on and off)
+/// displayed or not. Currently there are just two settings (on and off).
+///
+/// This can’t be done in exa’s own option parsing because that part of it
+/// logs as well, so by the time execution gets there, the logger needs to
+/// have already been set up.
 pub fn configure_logger() {
     extern crate env_logger;
     extern crate log;
 
-    let present = match var_os("EXA_DEBUG") {
+    let present = match var_os(exa::vars::EXA_DEBUG) {
         Some(debug)  => debug.len() > 0,
         None         => false,
     };

+ 1 - 0
src/exa.rs

@@ -33,6 +33,7 @@ use fs::{Dir, File};
 use fs::feature::ignore::IgnoreCache;
 use fs::feature::git::GitCache;
 use options::{Options, Vars};
+pub use options::vars;
 pub use options::Misfire;
 use output::{escape, lines, grid, grid_details, details, View, Mode};
 

+ 5 - 0
src/options/vars.rs

@@ -24,8 +24,13 @@ pub static EXA_COLORS: &str = "EXA_COLORS";
 /// complaining if an argument was specified twice, or if two conflict.
 /// This is meant to be so you don’t accidentally introduce the wrong
 /// behaviour in a script, rather than for general command-line use.
+/// Any non-empty value will turn strict mode on.
 pub static EXA_STRICT: &str = "EXA_STRICT";
 
+/// Environment variable used to make exa print out debugging information as
+/// it runs. Any non-empty value will turn debug mode on.
+pub static EXA_DEBUG: &str = "EXA_DEBUG";
+
 /// Environment variable used to limit the grid-details view
 /// (`--grid --long`) so it’s only activated if there’s at least the given
 /// number of rows of output.