23 lines
402 B
Go
23 lines
402 B
Go
package cmd
|
|
|
|
import (
|
|
"gosh/types"
|
|
"gosh/utils"
|
|
"os"
|
|
|
|
"github.com/fatih/color"
|
|
)
|
|
|
|
func GoshCat(sh *types.Shell, file_path string) types.CmdOutput {
|
|
|
|
file_path = utils.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)}
|
|
}
|