ColorTool: Proofread the helper text, update Build.bat (#2644)

First, my changes to `build.bat`:

1. `Build.bat` now looks for Visual Studio 2019 too.
2. `Build.bat` now ensures that the linker places ColorTool.exe into
   `\debug` or `\release` folders, not `\debug\net471` or
   `\release\net471`.
3. `Build.bat` is now smarter in its search. It determines the operating
   system's CPU architecture before deciding whether to search in "Program
   Files (x86)" or "Program Files".

Second, my changes to the help text displayed to the user:

1. The help text now makes it clear that some switches cannot be used
   with certain others.
2. Some typos are fixed. e.g. "ct" to "ColorTool" (it took me two hours
   to figure this one out!) and "schemename" to "scheme name".

I've made a minor change to the order of `switch (arg)` in Program.cs
too, to ensure that the terminating switches are analyzed first. This
way, there will be fewer surprises if the user supplies malformed input.
But feel free to reject this one.

# Unresolved issues

`Build.bat` is inherently faulty. On a pristine computer, a user cannot
just install the latest version of Microsoft Build Tool and run
`build.bat` to build ColorTool. The reason is the absence of certain
NuGet packages. Either NuGet or Visual Studio must download the
dependencies first.

# Validation Steps Performed

Since the changes to the code are minor, I don't know what test I can
possibly devise, other than compiling it and seeing that it works.
This commit is contained in:
skycommand 2019-12-04 00:14:23 +03:30 committed by Dustin L. Howett (MSFT)
parent 72761fceab
commit 5585183d7d
4 changed files with 299 additions and 268 deletions

View File

@ -32,10 +32,37 @@ namespace ColorTool
string arg = args[i];
switch (arg)
{
case "-?":
case "--help":
Usage();
return;
case "-c":
case "--current":
ColorTable.PrintTable();
return;
case "-l":
case "--location":
SchemeManager.PrintSchemesDirectory();
return;
case "-o":
case "--output":
if (i + 1 < args.Length)
{
new IniSchemeWriter().ExportCurrentAsIni(args[i + 1]);
}
else
{
OutputUsage();
}
return;
case "-s":
case "--schemes":
SchemeManager.PrintSchemes();
return;
case "-v":
case "--version":
Version();
return;
case "-e":
case "--errors":
reportErrors = true;
@ -54,18 +81,6 @@ namespace ColorTool
setDefaults = true;
setProperties = true;
break;
case "-?":
case "--help":
Usage();
return;
case "-v":
case "--version":
Version();
return;
case "-l":
case "--location":
SchemeManager.PrintSchemesDirectory();
return;
case "-x":
case "--xterm":
setUnixStyle = true;
@ -76,21 +91,6 @@ namespace ColorTool
setTerminalStyle = true;
setProperties = true;
break;
case "-o":
case "--output":
if (i + 1 < args.Length)
{
new IniSchemeWriter().ExportCurrentAsIni(args[i + 1]);
}
else
{
OutputUsage();
}
return;
case "-s":
case "--schemes":
SchemeManager.PrintSchemes();
return;
default:
break;
}
@ -127,7 +127,7 @@ namespace ColorTool
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var info = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
Console.WriteLine($"colortool v{info.FileVersion}");
Console.WriteLine($"ColorTool v{info.FileVersion}");
}
/// <summary>

View File

@ -139,30 +139,47 @@
</data>
<data name="Usage" xml:space="preserve">
<value>Usage:
colortool.exe [options] &lt;schemename&gt;
ColorTool.exe &lt;Function&gt;
ColorTool.exe [Options] &lt;Scheme name&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
Parameters:
&lt;Function&gt; : One and only one of the switches listed in the "Functions" section below.
&lt;Scheme name&gt;: The name of a color scheme. ColorTool 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:
Must be the last parameter passed to ColorTool.
[Option] : One or more of the switches listed in the "Options" section below. Must appear before scheme
name.
Functions:
You may specify only one of the following switches each time you invoke ColorTool. Any additional switches
before or after the first one of them will be ignored.
-?, --help : Display this help message
-c, --current : Print the color table for the currently applied scheme
-v, --version : Display the version number
-l, --location : Displays the full path to the schemes directory
-s, --schemes : Displays all available schemes
-o, --output &lt;filename&gt; : output the current color table to a file in .ini format
Options:
You may use these switches before a scheme name.
-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
By default, the scheme would be applied to the current console instead.
-b, --both : Apply the scheme to both the current console and the defaults.
By default, the scheme would be applied to the current console only.
-x, --xterm : Set the colors using VT sequences. Used for setting the colors in WSL.
Only works in Windows versions &gt;= 17048.
-t, --terminal : Output the colors in JSON format for copying into a Windows Terminal settings file.
-s, --schemes : Displays all available schemes
-l, --location : Displays the full path to the schemes directory
-v, --version : Display the version number
-o, --output &lt;filename&gt; : output the current color table to a file (in .ini format)
Available importers:
{0}</value>

View File

@ -2,40 +2,63 @@
ColorTool makes it easy to change the Windows console to your desired scheme. Includes support for iTerm themes!
```
```plain
Usage:
colortool.exe [options] <schemename>
ColorTool.exe <Function>
ColorTool.exe [Options] <Scheme name>
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.
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:
<schemename>: 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:
Parameters:
<Function> : One and only one of the switches listed in the "Functions" section below.
<Scheme name>: The name of a color scheme. ColorTool 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.
Must be the last parameter passed to ColorTool.
[Option] : One or more of the switches listed in the "Options" section below. Must appear before scheme
name.
Functions:
You may specify only one of the following switches each time you invoke ColorTool. Any additional switches
before or after the first one of them will be ignored.
-?, --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.
-s, --schemes : Display all available schemes
-v, --version : Display the version number
-l, --location : Displays the full path to the schemes directory
-s, --schemes : Displays all available schemes
-o, --output <filename> : output the current color table to a file in .ini format
Options:
You may use these switches before a scheme name.
-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
By default, the scheme would be applied to the current console instead.
-b, --both : Apply the scheme to both the current console and the defaults.
By default, the scheme would be applied to the current console only.
-x, --xterm : Set the colors using VT sequences. Used for setting the colors in WSL.
Only works in Windows versions >= 17048.
-t, --terminal : Output the colors in JSON format for copying into a Windows Terminal settings file.
```
## Included Schemes
Included are two important color schemes in .ini file format - `cmd-legacy` and `campbell`.
Included are two important color schemes in .ini file format: `cmd-legacy` and `campbell`.
* `cmd-legacy` is the legacy color scheme of the Windows Console, before July 2017
* `campbell` is the new default scheme used by the Windows Console Host, as of the Fall Creator's Update.
There are a few other schemes in that directory in both .ini format and .itermcolors.
## Adding Schemes
You can also add color schemes to the colortool easily. Take any existing scheme in `.itermcolors` format, and paste it in the `schemes/` directory. Or just cd into a directory containing `*.itermcolors` files before running the colortool.
You can also add color schemes to the ColorTool easily. Take any existing scheme in `.itermcolors` format, and paste it in the `schemes/` directory. Or just cd into a directory containing `*.itermcolors` files before running the ColorTool.
I recommend the excellent [iTerm2-Color-Schemes](https://github.com/mbadolato/iTerm2-Color-Schemes) repo, which has TONS of schemes to choose from, and previews.
@ -43,11 +66,11 @@ Options:
## Installing
Just [download the latest colortool release](https://github.com/microsoft/terminal/releases/tag/1904.29002) and extract the zip file.
Just [download the latest ColorTool release](https://github.com/microsoft/terminal/releases/tag/1904.29002) and extract the zip file.
## Building
Either build with Visual Studio, or use the included `build.bat` from the command line to try and auto-detect your msbuild version.
Either build with Visual Studio, or use the included `build.bat` from the command line to try and auto-detect your MSBuild version.
## Contributing

View File

@ -6,48 +6,39 @@ for /f "usebackq tokens=*" %%f in (`where.exe msbuild.exe 2^>nul`) do (
set MSBUILD="%%~ff"
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" (
set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe"
set AppFiles=%ProgramFiles(x86)%
if NOT %PROCESSOR_ARCHITECTURE%==AMD64 set AppFiles=%ProgramFiles%
set MSBUILD="%AppFiles%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
if exist %MSBUILD% (
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" (
set MSBUILD="%ProgramFiles%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe"
set MSBUILD="%AppFiles%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe"
if exist %MSBUILD% (
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" (
set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe"
set MSBUILD="%AppFiles%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe"
if exist %MSBUILD% (
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" (
set MSBUILD="%ProgramFiles%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe"
set MSBUILD="%AppFiles%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe"
if exist %MSBUILD% (
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" (
set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe"
set MSBUILD="%AppFiles%\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
if exist %MSBUILD% (
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" (
set MSBUILD="%ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe"
set MSBUILD="%AppFiles%\MSBuild\14.0\bin\msbuild.exe"
if exist %MSBUILD% (
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe" (
set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles(x86)%\MSBuild\14.0\bin" (
set MSBUILD="%ProgramFiles(x86)%\MSBuild\14.0\bin\msbuild.exe"
goto :FOUND_MSBUILD
)
if exist "%ProgramFiles%\MSBuild\14.0\bin" (
set MSBUILD="%ProgramFiles%\MSBuild\14.0\bin\msbuild.exe"
goto :FOUND_MSBUILD
)
if %MSBUILD%==() (
echo "I couldn't find MSBuild on your PC. Make sure it's installed somewhere, and if it's not in the above if statements (in build.bat), add it."
echo "MSBuild was not found. Make sure it is installed and included in the search path."
goto :EXIT
)
:FOUND_MSBUILD
echo MSBuild was found at %MSBUILD%
echo.
set _MSBUILD_TARGET=Build
set _MSBUILD_CONFIG=Debug
@ -63,17 +54,17 @@ shift
goto :ARGS_LOOP
:POST_ARGS_LOOP
%MSBUILD% %~dp0ColorTool.sln /t:%_MSBUILD_TARGET% /m /nr:true /p:Configuration=%_MSBUILD_CONFIG%
%MSBUILD% %~dp0ColorTool.sln /t:%_MSBUILD_TARGET% /m /nr:true /p:Configuration=%_MSBUILD_CONFIG% /p:OutputPath=.\bin\%_MSBUILD_CONFIG%\
if (%ERRORLEVEL%) == (0) (
echo.
echo Created exe in:
echo %~dp0ColorTool\bin\%_MSBUILD_CONFIG%\colortool.exe
echo %~dp0ColorTool\bin\%_MSBUILD_CONFIG%\ColorTool.exe
echo.
echo Copying exe to root of project...
copy %~dp0ColorTool\bin\%_MSBUILD_CONFIG%\colortool.exe %~dp0colortool.exe
echo Done.
copy %~dp0ColorTool\bin\%_MSBUILD_CONFIG%\colortool.exe %~dp0ColorTool.exe
echo.
)
:EXIT
Pause