github.com/jmigpin/editor@v1.6.0/core/internalcmds/listdir.go (about)

     1  package internalcmds
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/jmigpin/editor/core"
     7  )
     8  
     9  func ListDir(args0 *core.InternalCmdArgs) error {
    10  	erow := args0.ERow
    11  	part := args0.Part
    12  
    13  	if !erow.Info.IsDir() {
    14  		return fmt.Errorf("not a directory")
    15  	}
    16  
    17  	tree, hidden := false, false
    18  
    19  	args := part.Args[1:]
    20  	for _, a := range args {
    21  		s := a.UnquotedString()
    22  		switch s {
    23  		case "-sub":
    24  			tree = true
    25  		case "-hidden":
    26  			hidden = true
    27  		}
    28  	}
    29  
    30  	core.ListDirERow(erow, erow.Info.Name(), tree, hidden)
    31  
    32  	return nil
    33  }