added ~ as home processing
This commit is contained in:
1 parent
7062e798a9
commit
9e46cc9105
7 files changed
+79
-6
No files matched your search
@@ -2,14 +2,27 @@ package cmd
|
||||
|
||||
import (
|
||||
"gosh/types"
|
||||
"gosh/util"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func GoshLs(sh *types.Shell) types.CmdOutput {
|
||||
children, err := os.ReadDir(sh.Cd)
|
||||
func GoshLs(sh *types.Shell, paths ...string) types.CmdOutput {
|
||||
|
||||
var dir string
|
||||
|
||||
if len(paths) > 0 && paths[0] != "" {
|
||||
dir = paths[0]
|
||||
} else {
|
||||
dir = sh.Cd
|
||||
}
|
||||
|
||||
dir = util.ExpandHome(dir)
|
||||
|
||||
children, err := os.ReadDir(dir)
|
||||
|
||||
red := color.New(color.FgRed).SprintFunc()
|
||||
if err != nil {
|
||||
return types.CmdOutput{Id: 1, Output: red(err)}
|
||||
|
||||
Reference in new issue
Block a user