init
This commit is contained in:
commit
f6140a1fc3
11 files changed
+308
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"gosh/types"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func GoshLs(sh *types.Shell) types.CmdOutput {
|
||||
children, err := os.ReadDir(sh.Cd)
|
||||
red := color.New(color.FgRed).SprintFunc()
|
||||
if err != nil {
|
||||
return types.CmdOutput{Id: 1, Output: red(err)}
|
||||
}
|
||||
|
||||
var output strings.Builder
|
||||
for _, child := range children {
|
||||
if child.IsDir() {
|
||||
output.WriteString(color.CyanString(child.Name()+"/") + "\n")
|
||||
} else {
|
||||
output.WriteString(child.Name() + "\n")
|
||||
}
|
||||
}
|
||||
|
||||
return types.CmdOutput{Id: 0, Output: output.String()}
|
||||
}
|
||||
Reference in new issue
Block a user