CliTool constructor

CliTool({
  1. required String executable,
  2. int? windowsCodePage = WindowsCodePage.utf8,
})

Implementation

CliTool({
  required String executable,
  this.windowsCodePage = WindowsCodePage.utf8,
}) : originalExecutable = executable {
  if (io.Platform.isWindows && null != windowsCodePage) {
    final batchFile = io.Directory.systemTemp.file(
      "${DateTime.now().microsecondsSinceEpoch}.bat",
    );
    writeWindowsBatchScriptSync(
      file: batchFile,
      contents: """
@echo off
REM Change code page
chcp $windowsCodePage > nul

REM Forward arguments to the actual executable
$executable %*
""",
    );
    this.executable = batchFile.path;
  } else {
    this.executable = executable;
  }
}