diff --git a/cmd/gtree/main.go b/cmd/gtree/main.go index b44b0aa..2bff9aa 100644 --- a/cmd/gtree/main.go +++ b/cmd/gtree/main.go @@ -192,6 +192,9 @@ func actionOutput(c *cli.Context) error { return exitErrOpts(err) } options := []gtree.Option{oi, oo} + if c.Bool("massive") { + options = append(options, gtree.WithMassive()) + } markdownPath := c.Path("file") if isInputStdin(markdownPath) { @@ -239,6 +242,9 @@ func actionMkdir(c *cli.Context) error { } oe := gtree.WithFileExtensions(c.StringSlice("extension")) options := []gtree.Option{oi, oe} + if c.Bool("massive") { + options = append(options, gtree.WithMassive()) + } if c.Bool("dry-run") { if err := outputWithValidation(in, options); err != nil { diff --git a/simple_tree_grower.go b/simple_tree_grower.go index e9d7532..430194a 100644 --- a/simple_tree_grower.go +++ b/simple_tree_grower.go @@ -106,12 +106,6 @@ func (*defaultGrowerSimple) assembleBranchFinally(current, root *Node) { if root != nil { current.setPath(root.path(), current.path()) } - - if current.isRoot() { - current.setBranch(current.name, "\n") - } else { - current.setBranch(current.branch(), " ", current.name, "\n") - } } func (dg *defaultGrowerSimple) enableValidation() { diff --git a/simple_tree_spreader.go b/simple_tree_spreader.go index 064a1ab..3ba9f8e 100644 --- a/simple_tree_spreader.go +++ b/simple_tree_spreader.go @@ -59,7 +59,11 @@ func (ds *defaultSpreaderSimple) spread(w io.Writer, roots []*Node) error { } func (*defaultSpreaderSimple) spreadBranch(current *Node) string { - ret := current.branch() + ret := current.name + "\n" + if !current.isRoot() { + ret = current.branch() + " " + current.name + "\n" + } + for _, child := range current.children { ret += (*defaultSpreaderSimple)(nil).spreadBranch(child) } @@ -96,21 +100,26 @@ func (cs *colorizeSpreaderSimple) spread(w io.Writer, roots []*Node) error { } func (cs *colorizeSpreaderSimple) spreadBranch(current *Node) string { - cs.colorize(current) - ret := current.branch() + ret := "" + if current.isRoot() { + ret = cs.colorize(current) + "\n" + } else { + ret = current.branch() + " " + cs.colorize(current) + "\n" + } + for _, child := range current.children { ret += cs.spreadBranch(child) } return ret } -func (cs *colorizeSpreaderSimple) colorize(current *Node) { +func (cs *colorizeSpreaderSimple) colorize(current *Node) string { if cs.fileConsiderer.isFile(current) { _ = cs.fileCounter.next() - current.name = cs.fileColor.Sprint(current.name) + return cs.fileColor.Sprint(current.name) } else { _ = cs.dirCounter.next() - current.name = cs.dirColor.Sprint(current.name) + return cs.dirColor.Sprint(current.name) } }