Import "containerd/console" lib to support colorful output in Windows terminal

This commit is contained in:
vinjn
2023-11-23 22:21:32 -08:00
committed by jmorganca
parent 29e90cc13b
commit 66ef308abd
4 changed files with 13 additions and 23 deletions

View File

@@ -16,10 +16,13 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
"syscall"
"time"
"github.com/containerd/console"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh"
@@ -810,6 +813,11 @@ func NewCLI() *cobra.Command {
log.SetFlags(log.LstdFlags | log.Lshortfile)
cobra.EnableCommandSorting = false
if runtime.GOOS == "windows" {
// Enable colorful ANSI escape code in Windows terminal (disabled by default)
console.ConsoleFromFile(os.Stdout)
}
rootCmd := &cobra.Command{
Use: "ollama",
Short: "Large language model runner",