Skip to content

Commit

Permalink
Merge pull request #1 from Algebra8/v0.2.0
Browse files Browse the repository at this point in the history
Add package level convenience functions
  • Loading branch information
Algebra8 authored Jul 22, 2022
2 parents 9dac22a + 80ece3b commit 95cae95
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions treefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ const (
spacePrefix = " "
)

// Tree returns the graph, and metadata, of the fs.FS fsys with name name.
func Tree(fsys fs.FS, name string) (string, error) {
tfs, err := New(fsys, name)
if err != nil {
return "", err
}
return tfs.String(), nil
}

// Graph returns only the graph of the fs.FS fsys with name name.
func Graph(fsys fs.FS, name string) (string, error) {
tfs, err := New(fsys, name)
if err != nil {
return "", err
}
return tfs.Graph(), nil
}

// Meta returns only the stringified metadata of the fs.FS fsys with name name.
func Meta(fsys fs.FS, name string) (string, error) {
tfs, err := New(fsys, name)
if err != nil {
return "", err
}
return tfs.Meta(), nil
}

// New returns a TreeFS whose stringer interface implementation returns the
// graph for the fs.FS fsys and name name, similar to the `tree` command.
//
Expand Down

0 comments on commit 95cae95

Please sign in to comment.