package commands import ( "strings" "git.snorba.art/hugo/nssh/storage" ) type MkdirCommand struct { filestore storage.Filestore } func (c *MkdirCommand) Execute(arguments []string) error { for _, dir := range arguments { if len(dir) > 0 && dir[0] != '-' { var currentPath string for _, part := range strings.Split(dir, "/") { if part == "" { continue } currentPath += "/" + part if exists, _ := c.filestore.DirectoryExists(currentPath); !exists { err := c.filestore.MakeDirectory(currentPath) if err != nil { return err } } } } } return nil }