GoLSh/cmd/cat.go
2025-06-27 11:23:15 -05:00

23 lines
400 B
Go

package cmd
import (
"gosh/types"
"gosh/util"
"os"
"github.com/fatih/color"
)
func GoshCat(sh *types.Shell, file_path string) types.CmdOutput {
file_path = util.ExpandHome(file_path)
data, err := os.ReadFile(file_path)
red := color.New(color.FgRed).SprintFunc()
if err != nil {
return types.CmdOutput{Id: 1, Output: red(err)}
}
return types.CmdOutput{Id: 0, Output: string(data)}
}