Merge pull request #378 from devhawk/devhawk/errorsArg

Don't report scheme parse errors by default
This commit is contained in:
Michael Niksa 2019-02-27 12:57:12 -08:00 committed by GitHub
commit 52ef47533b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 31 deletions

View file

@ -9,6 +9,6 @@ namespace ColorTool
{
string Name { get; }
ColorScheme ParseScheme(string schemeName, bool reportErrors = true);
ColorScheme ParseScheme(string schemeName, bool reportErrors = false);
}
}

View file

@ -76,7 +76,7 @@ namespace ColorTool
return Scheme.GetSearchPaths(schemeName, ".ini").FirstOrDefault(File.Exists);
}
public ColorScheme ParseScheme(string schemeName, bool reportErrors = true)
public ColorScheme ParseScheme(string schemeName, bool reportErrors = false)
{
bool success = true;

View file

@ -60,7 +60,7 @@ namespace ColorTool
return null;
}
public ColorScheme ParseScheme(string schemeName, bool reportErrors = true)
public ColorScheme ParseScheme(string schemeName, bool reportErrors = false)
{
XmlDocument xmlDoc = loadJsonFile(schemeName);
if (xmlDoc == null) return null;

View file

@ -106,6 +106,7 @@ namespace ColorTool
};
static bool quietMode = false;
static bool reportErrors = false;
static bool setDefaults = false;
static bool setProperties = true;
static bool setUnixStyle = false;
@ -480,6 +481,10 @@ namespace ColorTool
case "--current":
PrintTable();
return;
case "-e":
case "--errors":
reportErrors = true;
break;
case "-q":
case "--quiet":
quietMode = true;
@ -529,7 +534,7 @@ namespace ColorTool
string schemeName = args[args.Length - 1];
ColorScheme colorScheme = GetScheme(schemeName);
ColorScheme colorScheme = GetScheme(schemeName, reportErrors);
if (colorScheme == null)
{
@ -561,7 +566,7 @@ namespace ColorTool
.Select(t => (ISchemeParser)Activator.CreateInstance(t));
}
private static ColorScheme GetScheme(string schemeName, bool reportErrors = true)
private static ColorScheme GetScheme(string schemeName, bool reportErrors = false)
{
foreach (var parser in GetParsers())
{

View file

@ -121,8 +121,8 @@
<value>Error loading ini file "{0}"</value>
</data>
<data name="IniParseError" xml:space="preserve">
<value>Error loading ini file "{0}"
for key "{1}"
<value>Error loading ini file "{0}"
for key "{1}"
the value "{2}" is invalid</value>
</data>
<data name="InvalidColor" xml:space="preserve">
@ -138,29 +138,31 @@
<value>Could not find or load "{0}"</value>
</data>
<data name="Usage" xml:space="preserve">
<value>Usage:
colortool.exe [options] &lt;schemename&gt;
ColorTool is a utility for helping to set the color palette of the Windows Console.
By default, applies the colors in the specified .itermcolors or .ini file to the current console window.
This does NOT save the properties automatically. For that, you'll need to open the properties sheet and hit "Ok".
Included should be a `schemes/` directory with a selection of schemes of both formats for examples.
Feel free to add your own preferred scheme to that directory.
Arguments:
&lt;schemename&gt;: The name of a color scheme. ct will try to first load it as an .itermcolors color scheme.
If that fails, it will look for it as an .ini file color scheme.
Options:
-?, --help : Display this help message
-c, --current : Print the color table for the currently applied scheme
-q, --quiet : Don't print the color table after applying
-d, --defaults : Apply the scheme to only the defaults in the registry
-b, --both : Apply the scheme to both the current console and the defaults.
-x, --xterm : Set the colors using VT sequences. Used for setting the colors in WSL.
Only works in Windows versions &gt;= 17048.
-s, --schemes : Displays all available schemes
-v, --version : Display the version number
-o, --output &lt;filename&gt; : output the current color table to an file (in .ini format)
Available importers:
<value>Usage:
colortool.exe [options] &lt;schemename&gt;
ColorTool is a utility for helping to set the color palette of the Windows Console.
By default, applies the colors in the specified .itermcolors, .json or .ini file to the current console window.
This does NOT save the properties automatically. For that, you'll need to open the properties sheet and hit "Ok".
Included should be a `schemes/` directory with a selection of schemes of both formats for examples.
Feel free to add your own preferred scheme to that directory.
Arguments:
&lt;schemename&gt;: The name of a color scheme. ct will try to first load it as an .ini file color scheme
If that fails, it will look for it as a .json file color scheme
If that fails, it will look for it as an .itermcolors file color scheme.
Options:
-?, --help : Display this help message
-c, --current : Print the color table for the currently applied scheme
-q, --quiet : Don't print the color table after applying
-e, --errors : Report scheme parsing errors on the console
-d, --defaults : Apply the scheme to only the defaults in the registry
-b, --both : Apply the scheme to both the current console and the defaults.
-x, --xterm : Set the colors using VT sequences. Used for setting the colors in WSL.
Only works in Windows versions &gt;= 17048.
-s, --schemes : Displays all available schemes
-v, --version : Display the version number
-o, --output &lt;filename&gt; : output the current color table to an file (in .ini format)
Available importers:
{0}</value>
</data>
<data name="WroteToDefaults" xml:space="preserve">

View file

@ -99,7 +99,7 @@ namespace ColorTool
}
public ColorScheme ParseScheme(string schemeName, bool reportErrors = true)
public ColorScheme ParseScheme(string schemeName, bool reportErrors = false)
{
XmlDocument xmlDoc = loadXmlScheme(schemeName); // Create an XML document object
if (xmlDoc == null) return null;