Skip to content

CrosleyZack/xplr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xplr


License Release CI

Xplr allows you explore tree-based file formats as an interactive TUI tree. This currently supports JSON, YAML, and TOML files.

example

Installation

Can be installed using Go 1.23+ via:

go install github.com/crosleyzack/xplr@latest

Examples

Xplr can take in data by providing a data file:

xplr -f foo.toml

or by passing it as the first argument:

xplr "{\"foo\": \"bar\"}"

or finally via stdin:

cat bar.yml | xplr -x 1

Configuration

Xplr will search for a configuration toml file at:

  1. $XPLR_CONFIG
  2. $XDG_CONFIG_HOME/xplr/config.toml

Configuration options include:

# format
ExpandedShape = "╰─"
ExpandableShape = ""
LeafShape = "└─"
SpacesPerLayer = 2
HideSummaryWhenExpanded = false
# colors
ExpandedShapeColor = "#d99c63"
ExpandableShapeColor = "#d19359"
LeafShapeColor = "#d19359"
SelectedForegroundColor = "#fffffb"
SelectedBackgroundColor = "#63264A"
UnselectedForegroundColor = "#fffffd"
HelpColor = "#fffffe"
# keys
BottomKeys = ["bottom", "G"]
TopKeys = ["top", "g"]
DownKeys = ["down","j"]
UpKeys = ["up","k"]
CollapseToggleKeys = ["tab", "h", "l"]
CollapseAllKeys = ["<", "H"]
ExpandAllKeys = [">", "L"]
HelpKeys = ["?"]
QuitKeys = ["esc","q"]
SearchKeys = ["/"]
SubmitKeys = ["enter"]
NextKeys = ["n"]

Tree View in your TUI

Xplr tree view can be embedded in your own application by:

  1. Convert your data to a map[string]any type. Examples exist in the pkg/format package for JSON, YAML, and TOML.
  2. Call pkg/nodes.New to convert your map[string]any to a []nodes.Nodes tree.
  3. Call pkg/modules/tree.New with the []nodes.Nodes tree as well as your desired pkg/modules/tree.TreeFormat, pkg/keys.KeyMap, and pkg/style.Style to create the tree view bubbletea tree module.
  4. Create a new bubbletea program with the tree module, or add the tree module to your existing bubbletea program.

About

A TUI Tree View for Data Files

Topics

Resources

License

Stars

Watchers

Forks

Languages