diff --git a/source/dub/commandline.d b/source/dub/commandline.d index e3d54b5..53b8516 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -519,8 +519,8 @@ auto remaining_args = command_args.extractRemainingArgs(); if (remaining_args.any!(a => a.startsWith("-"))) { - logError("Unknown command line flags: %s", remaining_args.filter!(a => a.startsWith("-")).array.join(" ")); - logError(`Type "dub %s -h" to get a list of all supported flags.`, cmd.name); + logError("Unknown command line flags: %s", remaining_args.filter!(a => a.startsWith("-")).array.join(" ").color(Mode.bold)); + logInfo(`Type "%s" to get a list of all supported flags.`, text("dub ", cmd.name, " -h").color(Mode.bold)); return 1; } @@ -803,12 +803,12 @@ if (filePath.empty) { if (warn_missing_package) { - logInfo(""); - logInfo("No package manifest (dub.json or dub.sdl) was found in"); - logInfo(dub.rootPath.toNativeString()); - logInfo("Please run DUB from the root directory of an existing package, or run"); - logInfo("\"dub init --help\" to get information on creating a new package."); - logInfo(""); + logInfoNoTag(""); + logInfoNoTag("No package manifest (dub.json or dub.sdl) was found in"); + logInfoNoTag(dub.rootPath.toNativeString()); + logInfoNoTag("Please run DUB from the root directory of an existing package, or run"); + logInfoNoTag("\"%s\" to get information on creating a new package.", "dub init --help".color(Mode.bold)); + logInfoNoTag(""); } return false; } @@ -2126,7 +2126,7 @@ logInfoNoTag("Packages present in the system and known to dub:"); foreach (p; dub.packageManager.getPackageIterator()) { if ((pname == "" || pname == p.name) && pvlim.matches(p.version_)) - logInfo(" %s %s: %s", p.name.color(Mode.bold), p.version_, p.path.toNativeString()); + logInfoNoTag(" %s %s: %s", p.name.color(Mode.bold), p.version_, p.path.toNativeString()); } logInfo(""); return 0; @@ -2159,11 +2159,14 @@ .map!(m => m.name.length + m.version_.length) .reduce!max + " ()".length; justify += (~justify & 3) + 1; // round to next multiple of 4 + int colorDifference = cast(int)"a".color(Mode.bold).length - 1; + justify += colorDifference; foreach (desc, matches; res) { logInfoNoTag("==== %s ====", desc); foreach (m; matches) - logInfoNoTag(" %s%s", leftJustify(m.name ~ " (" ~ m.version_ ~ ")", justify), m.description); + logInfoNoTag(" %s%s", leftJustify(m.name.color(Mode.bold) + ~ " (" ~ m.version_ ~ ")", justify), m.description); } return 0; } @@ -2264,10 +2267,10 @@ void printList(in PackageOverride[] overrides, string caption) { if (overrides.length == 0) return; - logInfo("# %s", caption); + logInfoNoTag("# %s", caption); foreach (ovr; overrides) ovr.target.match!( - t => logInfo("%s %s => %s", ovr.package_, ovr.version_, t)); + t => logInfoNoTag("%s %s => %s", ovr.package_.color(Mode.bold), ovr.version_, t)); } printList(dub.packageManager.getOverrides(PlacementLocation.user), "User wide overrides"); printList(dub.packageManager.getOverrides(PlacementLocation.system), "System wide overrides"); @@ -2376,11 +2379,11 @@ gensettings.runCallback = check(m_programStatusCode, m_programRegex); try dub.generateProject("build", gensettings); catch (DustmiteMismatchException) { - logInfo("Dustmite test doesn't match."); + logInfoNoTag("Dustmite test doesn't match."); return 3; } catch (DustmiteMatchException) { - logInfo("Dustmite test matches."); + logInfoNoTag("Dustmite test matches."); return 0; } } else { @@ -2445,7 +2448,7 @@ if (pack.name in visited) continue; visited[pack.name] = true; auto dst_path = path ~ pack.name; - logInfo("Copy package '%s' to destination folder...", pack.name); + logInfo("Prepare", Color.light_blue, "Copy package %s to destination folder...", pack.name.color(Mode.bold)); copyFolderRec(pack.path, dst_path); // adjust all path based dependencies @@ -2455,7 +2458,7 @@ pack.storeInfo(dst_path); } - logInfo("Executing dustmite..."); + logInfo("Starting", Color.light_green, "Executing dustmite..."); auto testcmd = appender!string(); testcmd.formattedWrite("%s dustmite --test-package=%s --build=%s --config=%s", thisExePath, prj.name, this.baseSettings.buildType, this.baseSettings.config); diff --git a/source/dub/dependency.d b/source/dub/dependency.d index 723c56a..375caf6 100644 --- a/source/dub/dependency.d +++ b/source/dub/dependency.d @@ -682,7 +682,7 @@ */ this(string remote, string ref_) { - enforce(remote.startsWith("git+"), "Unsupported repository type"); + enforce(remote.startsWith("git+"), "Unsupported repository type (supports: git+URL)"); m_remote = remote["git+".length .. $]; m_kind = Kind.git; @@ -695,7 +695,7 @@ deprecated("Use the constructor accepting a second parameter named `ref_`") this(string remote) { - enforce(remote.startsWith("git+"), "Unsupported repository type"); + enforce(remote.startsWith("git+"), "Unsupported repository type (supports: git+URL)"); m_remote = remote["git+".length .. $]; m_kind = Kind.git; diff --git a/source/dub/dub.d b/source/dub/dub.d index 2057b3e..59e4b36 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -24,13 +24,13 @@ import std.algorithm; import std.array : array, replace; -import std.conv : to; +import std.conv : text, to; +import std.encoding : sanitize; import std.exception : enforce; import std.file; import std.process : environment; import std.range : assumeSorted, empty; import std.string; -import std.encoding : sanitize; // Set output path and options for coverage reports version (DigitalMars) version (D_Coverage) @@ -556,7 +556,7 @@ basename.color(Mode.bold), sver, ver); any = true; } - if (any) logInfo("Use \"dub upgrade\" to perform those changes"); + if (any) logInfo("Use \"%s\" to perform those changes", "dub upgrade".color(Mode.bold)); return; } @@ -663,7 +663,7 @@ auto tool_pack = m_packageManager.getBestPackage(tool, ">=0.0.0"); if (!tool_pack) tool_pack = m_packageManager.getBestPackage(tool, "~master"); if (!tool_pack) { - logInfo("%s is not present, getting and storing it user wide", tool); + logInfo("Hint", Color.light_blue, "%s is not present, getting and storing it user wide", tool); tool_pack = fetch(tool, Dependency.any, defaultPlacementLocation, FetchOptions.none); } @@ -769,8 +769,9 @@ Package existing = m_packageManager.getPackage(packageId, ver, placement); if (options & FetchOptions.printOnly) { if (existing && existing.version_ != Version(ver)) - logInfo("A new version for %s is available (%s -> %s). Run \"dub upgrade %s\" to switch.", - packageId, existing.version_, ver, packageId); + logInfo("A new version for %s is available (%s -> %s). Run \"%s\" to switch.", + packageId.color(Mode.bold), existing.version_, ver, + text("dub upgrade ", packageId).color(Mode.bold)); return null; } diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 09ef0fa..cd07742 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -624,7 +624,7 @@ in BuildSettings buildsettings) { if (buildsettings.preRunCommands.length) { - logInfo("Running pre-run commands..."); + logInfo("Pre-run", Color.light_green, "Running commands..."); runBuildCommands(CommandType.preRun, buildsettings.preRunCommands, pack, proj, settings, buildsettings); } } @@ -633,7 +633,7 @@ in BuildSettings buildsettings) { if (buildsettings.postRunCommands.length) { - logInfo("Running post-run commands..."); + logInfo("Post-run", Color.light_green, "Running commands..."); runBuildCommands(CommandType.postRun, buildsettings.postRunCommands, pack, proj, settings, buildsettings); } } diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index ba14278..3519cce 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -277,8 +277,8 @@ } } if (tt != TargetType.none && tt != TargetType.sourceLibrary && ti.buildSettings.sourceFiles.empty) { - logWarn(`Configuration '%s' of package %s contains no source files. Please add {"targetType": "none"} to its package description to avoid building it.`, - ti.config, ti.pack.name); + logWarn(`Configuration [%s] of package %s contains no source files. Please add %s to its package description to avoid building it.`, + ti.config.color(Color.blue), ti.pack.name.color(Mode.bold), `{"targetType": "none"}`.color(Mode.bold)); tt = TargetType.none; } return tt; diff --git a/source/dub/project.d b/source/dub/project.d index bf588bb..eee524a 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -417,16 +417,17 @@ // search for orphan sub configurations void warnSubConfig(string pack, string config) { - logWarn("The sub configuration directive \"%s\" -> \"%s\" " + logWarn("The sub configuration directive \"%s\" -> [%s] " ~ "references a package that is not specified as a dependency " - ~ "and will have no effect.", pack, config); + ~ "and will have no effect.", pack.color(Mode.bold), config.color(Color.blue)); } + void checkSubConfig(string pack, string config) { auto p = getDependency(pack, true); if (p && !p.configurations.canFind(config)) { - logWarn("The sub configuration directive \"%s\" -> \"%s\" " + logWarn("The sub configuration directive \"%s\" -> [%s] " ~ "references a configuration that does not exist.", - pack, config); + pack.color(Mode.bold), config.color(Color.red)); } } auto globalbs = m_rootPackage.getBuildSettings(); @@ -454,8 +455,8 @@ if (m_selections.hasSelectedVersion(basename)) { auto selver = m_selections.getSelectedVersion(basename); if (d.spec.merge(selver) == Dependency.invalid) { - logWarn("Selected package %s %s does not match the dependency specification %s in package %s. Need to \"dub upgrade\"?", - basename, selver, d.spec, pack.name); + logWarn("Selected package %s %s does not match the dependency specification %s in package %s. Need to \"%s\"?", + basename.color(Mode.bold), selver, d.spec, pack.name.color(Mode.bold), "dub upgrade".color(Mode.bold)); } } diff --git a/test/expected-issue1037-output b/test/expected-issue1037-output index 9cbae84..2f19647 100644 --- a/test/expected-issue1037-output +++ b/test/expected-issue1037-output @@ -1,3 +1,3 @@ - Error Unresolvable dependencies to package gitcompatibledubpackage: +Error Unresolvable dependencies to package gitcompatibledubpackage: b @DIR/b depends on gitcompatibledubpackage ~>1.0.2 issue1037-better-dependency-messages ~master depends on gitcompatibledubpackage 1.0.1 diff --git a/test/issue1194-warn-wrong-subconfig.sh b/test/issue1194-warn-wrong-subconfig.sh index 414bfe2..2bb7e54 100755 --- a/test/issue1194-warn-wrong-subconfig.sh +++ b/test/issue1194-warn-wrong-subconfig.sh @@ -3,12 +3,14 @@ OUTPUT=`${DUB} build --root ${CURR_DIR}/issue1194-warn-wrong-subconfig 2>&1 || true` +trap 'printf "%s" "Failing received output:\n$OUTPUT" | hexdump -C' ERR + # make sure the proper errors occur in the output -echo $OUTPUT | grep -c "sub configuration directive \"bar\" -> \"baz\" references a package that is not specified as a dependency" > /dev/null -echo $OUTPUT | grep -c "sub configuration directive \"staticlib-simple\" -> \"foo\" references a configuration that does not exist" > /dev/null -! echo $OUTPUT | grep -c "sub configuration directive \"sourcelib-simple\" -> \"library\" references a package that is not specified as a dependency" > /dev/null -! echo $OUTPUT | grep -c "sub configuration directive \"sourcelib-simple\" -> \"library\" references a configuration that does not exist" > /dev/null +echo "$OUTPUT" | fgrep -c 'sub configuration directive "bar" -> [baz] references a package that is not specified as a dependency' > /dev/null +echo $OUTPUT | fgrep -c 'sub configuration directive "staticlib-simple" -> [foo] references a configuration that does not exist' > /dev/null +! echo $OUTPUT | fgrep -c 'sub configuration directive "sourcelib-simple" -> [library] references a package that is not specified as a dependency' > /dev/null +! echo $OUTPUT | fgrep -c 'sub configuration directive "sourcelib-simple" -> [library] references a configuration that does not exist' > /dev/null # make sure no bogs warnings are issued for packages with no sub configuration directives OUTPUT=`${DUB} build --root ${CURR_DIR}/1-exec-simple 2>&1` -! echo $OUTPUT | grep -c "sub configuration directive.*references" > /dev/null +! echo $OUTPUT | grep -c 'sub configuration directive.*references' > /dev/null