Skip to content

jeb-de/batcolors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batcolors

Levels of color used in a Windows bat script

BAT level colors

Description

Add log-level-like colored headers to your script output:

Usage

Clone batcolors into your bat script project and:

@echo off
setlocal enabledelayedexpansion

rem https://stackoverflow.com/questions/112055/what-does-d0-mean-in-a-windows-batch-file
for %%i in ("%~dp0.") do SET "script_dir=%%~fi"
set script_dir=%script_dir%\..
@echo %script_dir%

call %script_dir%\batcolors\echos_macros.bat

%_ok%      "Result matches what was expected"
%_info%    "Describe what is about to be done"
%_warning% "Result was not expected, but non-blocking"
%_error%   "Result is wrong"
%_fatal%   "Program must stop and exit" 1

REM final echo should not be displayed:
echo done

%_error% will not exit your script, while %_fatal% will.
Any line after %_fatal% will not be executed (unless FATALNOEXIT is set. See below)

NOCOLORS

If you do not want ANSI escape code, simply set NOCOLORS=1.

Then unset it (set NOCOLORS=), and the next %_ok/info/...% call will display colors again.

FATALNOEXIT

If you don't want to exit on a %_fatal% call, set FATALNOEXIT=1 first.

Then, unset it (set FATALNOEXIT=), and the next %_fatal% call will exit the script.

License: MIT

LICENSE

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors