bionicles / tree_plus

A `tree` util enhanced with tokens, lines, and components. `pip install -U tree_plus`

Home Page:https://github.com/bionicles/tree_plus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tree Plus

License Docs Linux & MacOS Microsoft

Supported Operating Systems: Ubuntu MacOS Windows

Supported Python Versions: Python 3.8 Python 3.9 Python 3.10 Python 3.11

A simple command line interface (CLI) tool for developers to show a tree enhanced with token counts, line counts, and source code components.

Example Output:

  • Demonstrate Parsed Checkboxes
(py310) bion@WIN-QVRBL09D89C:~/hax/tree_plus$ tree_plus -i tests
πŸ“ tree_plus (20023 tokens, 2071 lines)
┣━━ πŸ“ .github
┃   ┗━━ πŸ“ workflows (503 tokens, 70 lines)
┃       ┣━━ πŸ“„ microsoft.yml (263 tokens, 36 lines)
┃       ┃   ┣━━ Microsoft
┃       ┃   ┣━━   job: build
┃       ┃   ┣━━     - Set up Python ${{ matrix.python-version }}
┃       ┃   ┣━━     - Install tree_plus
┃       ┃   ┣━━     - Set PYTHONUTF8 for Windows
┃       ┃   ┣━━     - Run generic tests
┃       ┃   ┗━━     - Run specific test
┃       ┗━━ πŸ“„ unix.yml (240 tokens, 34 lines)
┃           ┣━━ Ubuntu & MacOS
┃           ┣━━   job: build
┃           ┣━━     - Set up Python ${{ matrix.python-version }}
┃           ┣━━     - Install tree_plus
┃           ┣━━     - Run generic tests
┃           ┗━━     - Run specific test
┣━━ πŸ“ tree_plus_src (8776 tokens, 1088 lines)
┃   ┣━━ πŸ“„ __init__.py (64 tokens, 9 lines)
┃   ┣━━ πŸ“„ count_tokens_lines.py (461 tokens, 67 lines)
┃   ┃   ┣━━ TODO (Line 11): show off how well we parse_todo!
┃   ┃   ┣━━ class TokenLineCount
┃   ┃   ┣━━ def count_tokens_lines
┃   ┃   ┗━━ def count_directory_tokens_lines
┃   ┣━━ πŸ“„ traverse_directory.py (274 tokens, 39 lines)
┃   ┃   ┗━━ def traverse_directory
┃   ┣━━ πŸ“„ default_ignore.py (248 tokens, 53 lines)
┃   ┗━━ πŸ“„ parse_file.py (7729 tokens, 920 lines)
┃       ┣━━ def parse_file
┃       ┣━━ def is_k8s_yml
┃       ┣━━ def is_ansible_yml
┃       ┣━━ def is_github_yml
┃       ┣━━ def parse_github_yml
┃       ┣━━ def parse_k8s
┃       ┣━━ def parse_ansible
┃       ┣━━ def parse_yml
┃       ┣━━ def extract_nodes
┃       ┣━━ def is_typing_construct
┃       ┣━━ def is_builtin_type
┃       ┣━━ def parse_py
┃       ┣━━ def parse_db
┃       ┣━━ def parse_cobol
┃       ┣━━ def parse_java
┃       ┣━━ def parse_julia
┃       ┣━━ def parse_kotlin
┃       ┣━━ def parse_lisp
┃       ┣━━ def parse_lua
┃       ┣━━ def parse_objective_c
┃       ┣━━ def parse_ocaml
┃       ┣━━ def parse_apl
┃       ┣━━ def parse_perl
┃       ┣━━ def parse_php
┃       ┣━━ def parse_powershell
┃       ┣━━ def parse_matlab
┃       ┣━━ def parse_scala
┃       ┣━━ def parse_c
┃       ┣━━ def parse_rs
┃       ┣━━ def handle_block
┃       ┣━━ def parse_tf
┃       ┣━━ def parse_js
┃       ┣━━ def parse_md
┃       ┣━━ def parse_txt
┃       ┗━━ def parse_todo
┣━━ πŸ“„ Makefile (85 tokens, 16 lines)
┣━━ πŸ“„ README.md (4530 tokens, 319 lines)
┃   ┣━━ # Tree Plus
┃   ┣━━ ## Example Output:
┃   ┣━━ - [ ] Demonstrate Parsed Checkboxes
┃   ┣━━ ## Start Quick!
┃   ┗━━ ## Moar Usage
┣━━ πŸ“„ tree_plus_cli.py (2586 tokens, 298 lines)
┃   ┣━━ def main
┃   ┣━━ def tree_plus
┃   ┗━━ def tree_to_string
┣━━ πŸ“„ setup.py (393 tokens, 69 lines)
┃   ┗━━ TODO (Line 16): automatically install tree-sitter-{language} grammars
┣━━ πŸ“„ requirements.txt (11 tokens, 4 lines)
┣━━ πŸ“„ LICENSE (2123 tokens, 81 lines)
┣━━ πŸ“„ .gitignore (97 tokens, 28 lines)
┗━━ πŸ“„ sample_output.sh (3039 tokens, 184 lines)
  • Demonstrate Parsed Checkboxes

Start Quick!

Prerequisites

Ensure you have the following tools installed:

Install Tree Plus

Local Hackable Install

  1. Clone the repository and cd into the tree_plus directory
gh repo clone https://github.com/bionicles/tree_plus.git && cd tree_plus
  1. Install tree_plus using Makefile
make cli

Alternatively, if make is not installed, use pip:

pip install -e .

Now, you can use the tree_plus command.

  1. Add slick aliases like tp to your RC file Typical RC_FILE values ~/.bash_profile, ~/.bashrc, or ~/.zshrc
RC_FILE=~/.bash_profile source alias_tree_plus.sh
RC_FILE=~/.bashrc source alias_tree_plus.sh
RC_FILE=~/.zshrc source alias_tree_plus.sh

Soon, you'll be able to simply run 'pip install tree_plus'. Stay tuned!

Usage

# Use tree_plus
tp

If you make changes to tree_plus and need to reinstall it quickly, use the tpcli alias:

# Reinstall tree_plus quickly after making changes
tpcli

Moar Usage

Multiple directories:

(py310) bion@WIN-QVRBL09D89C:~/hax/tree_plus$ tp tests/path_to_test,tests/more_languages/group1
Multiple Directories:
┣━━ πŸ“ path_to_test (153 tokens, 38 lines)
┃   ┣━━ πŸ“„ file.py (11 tokens, 2 lines)
┃   ┃   ┗━━ def hello_world
┃   ┣━━ πŸ“„ file.txt (11 tokens, 2 lines)
┃   ┣━━ πŸ“„ class_function_type.ts (45 tokens, 12 lines)
┃   ┃   ┣━━ type MyType
┃   ┃   ┣━━ class TsClass
┃   ┃   ┗━━ function tsFunction
┃   ┣━━ πŸ“„ file.js (14 tokens, 3 lines)
┃   ┃   ┗━━ function helloWorld
┃   ┣━━ πŸ“„ empty.py (0 tokens, 0 lines)
┃   ┣━━ πŸ“„ file.md (12 tokens, 2 lines)
┃   ┃   ┗━━ # Hello, world!
┃   ┣━━ πŸ“„ class_function.js (33 tokens, 9 lines)
┃   ┃   ┣━━ class MyClass
┃   ┃   ┗━━ function myFunction
┃   ┗━━ πŸ“„ class_method_type.py (27 tokens, 8 lines)
┃       ┣━━ MyType
┃       ┣━━ class MyClass
┃       ┗━━ class MyClass -> def my_method
┗━━ πŸ“ group1 (402 tokens, 88 lines)
    ┣━━ πŸ“„ KotlinTest.kt (29 tokens, 4 lines)
    ┃   ┣━━ data class Person(val name: String)
    ┃   ┗━━ fun greet(person: Person)
    ┣━━ πŸ“„ JavaTest.java (47 tokens, 12 lines)
    ┃   ┣━━ class Person
    ┃   ┣━━ class Person -> Person(String name)
    ┃   ┗━━ class Person -> void greet()
    ┣━━ πŸ“„ LispTest.lisp (31 tokens, 5 lines)
    ┃   ┣━━ defstruct person
    ┃   ┗━━ defun greet
    ┣━━ πŸ“„ ObjectiveCTest.m (59 tokens, 16 lines)
    ┃   ┣━━ @interface HelloWorld
    ┃   ┣━━ @interface HelloWorld -> (void) sayHello
    ┃   ┣━━ @implementation HelloWorld
    ┃   ┣━━ @implementation HelloWorld -> (void) sayHello
    ┃   ┗━━ void sayHelloWorld()
    ┣━━ πŸ“„ LuaTest.lua (84 tokens, 16 lines)
    ┃   ┣━━ function HelloWorld.new
    ┃   ┣━━ function HelloWorld.greet
    ┃   ┗━━ function say_hello
    ┣━━ πŸ“„ JuliaTest.jl (42 tokens, 12 lines)
    ┃   ┣━━ module JuliaTest
    ┃   ┣━━ module JuliaTest -> struct Person
    ┃   ┗━━ module JuliaTest -> greet(p::Person)
    ┣━━ πŸ“„ OcamlTest.ml (53 tokens, 12 lines)
    ┃   ┣━━ type color
    ┃   ┣━━ class hello
    ┃   ┣━━ class hello -> method say_hello
    ┃   ┗━━ let main ()
    ┗━━ πŸ“„ COBOL_TEST.CBL (57 tokens, 11 lines)
        ┣━━ IDENTIFICATION DIVISION -> PROGRAM-ID. HELLO
        ┣━━ DATA DIVISION -> 01 GREETING
        ┗━━ PROCEDURE DIVISION

About

A `tree` util enhanced with tokens, lines, and components. `pip install -U tree_plus`

https://github.com/bionicles/tree_plus

License:Other


Languages

Language:Python 63.6%Language:TypeScript 7.8%Language:C++ 7.6%Language:C 3.8%Language:PowerShell 3.1%Language:Isabelle 1.4%Language:TeX 1.3%Language:JavaScript 1.3%Language:COBOL 1.2%Language:Makefile 1.1%Language:Kotlin 0.8%Language:C# 0.8%Language:Rust 0.7%Language:Clojure 0.6%Language:Java 0.5%Language:Erlang 0.4%Language:Swift 0.4%Language:Haskell 0.3%Language:Zig 0.3%Language:Julia 0.3%Language:Shell 0.3%Language:R 0.3%Language:Scheme 0.3%Language:Lean 0.2%Language:HCL 0.2%Language:Fortran 0.1%Language:Go 0.1%Language:Scala 0.1%Language:Ruby 0.1%Language:Mathematica 0.1%Language:Cap'n Proto 0.1%Language:Dart 0.1%Language:SAS 0.1%Language:F# 0.1%Language:Lua 0.1%Language:PHP 0.1%Language:Visual Basic 6.0 0.1%Language:Perl 0.1%Language:Objective-C 0.1%Language:Tcl 0.0%Language:OCaml 0.0%Language:Crystal 0.0%Language:MATLAB 0.0%Language:Elixir 0.0%Language:Cuda 0.0%Language:APL 0.0%Language:Common Lisp 0.0%Language:Racket 0.0%