diff --git a/source/configy/Read.d b/source/configy/Read.d index 0089072..d486485 100644 --- a/source/configy/Read.d +++ b/source/configy/Read.d @@ -156,12 +156,14 @@ import std.getopt; import std.meta; import std.range; -import std.stdio; import std.traits; import std.typecons : Nullable, nullable, tuple; static import core.time; +// Dub-specific adjustments for output +import dub.internal.logging; + /// Command-line arguments public struct CLIArgs { @@ -304,7 +306,7 @@ { // Other Exception type may be thrown by D-YAML, // they won't include rich information. - stderr.writeln(exc.message()); + logWarn("%s", exc.message()); return typeof(return).init; } } @@ -319,18 +321,12 @@ private void printException (scope ConfigException exc) @trusted { - version (Posix) - { - import core.sys.posix.unistd : isatty; - const colors = isatty(stderr.fileno); - } - else - const colors = false; + import dub.internal.logging; - if (colors) - stderr.writefln("%S", exc); + if (hasColors) + logWarn("%S", exc); else - stderr.writefln("%s", exc.message()); + logWarn("%s", exc.message()); } /******************************************************************************* diff --git a/source/dub/dub.d b/source/dub/dub.d index 2900e3e..da6f3a5 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -271,9 +271,11 @@ // The default is to error, but as the previous parser wasn't // complaining, we should first warn the user. const path = path_.toNativeString(); - if (path.exists) - this.m_config = this.m_config.merge( - parseConfigFile!UserConfiguration(CLIArgs(path), StrictMode.Warn)); + if (path.exists) { + auto newConf = parseConfigFileSimple!UserConfiguration(path, StrictMode.Warn); + if (!newConf.isNull()) + this.m_config = this.m_config.merge(newConf.get()); + } } const dubFolderPath = NativePath(thisExePath).parentPath; diff --git a/source/dub/internal/logging.d b/source/dub/internal/logging.d index ecada55..3b45cf7 100644 --- a/source/dub/internal/logging.d +++ b/source/dub/internal/logging.d @@ -99,6 +99,9 @@ */ private shared bool _printColors = true; +/// Ditto +public bool hasColors () @trusted nothrow @nogc { return _printColors; } + // isatty() is used in initLogging() to detect whether or not we are on a TTY extern (C) int isatty(int); diff --git a/source/dub/project.d b/source/dub/project.d index c2c83c3..bf588bb 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -83,8 +83,8 @@ // The default is to error, but as the previous parser wasn't // complaining, we should first warn the user. auto selected = parseConfigFileSimple!Selected(selverfile, StrictMode.Warn); - enforce(!selected.isNull(), "Could not read '" ~ selverfile ~ "'"); - m_selections = new SelectedVersions(selected.get()); + m_selections = !selected.isNull() ? + new SelectedVersions(selected.get()) : new SelectedVersions(); } else m_selections = new SelectedVersions; reinit();