8000 GitHub - foundling/untree: create a file tree from tree output
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

foundling/untree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

untree: create a file tree from tree output

untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo untree logo

Motivation

tree is a widely-used and useful command-line tool. We see it often in code tutorials and reference documents.

Here's a real-world example of tree output from Real Python's article, Python import: Advanced Techniques and Tips:

world/
│
├── africa/
│   ├── __init__.py
│   └── zimbabwe.py
│
├── europe/
│   ├── __init__.py
│   ├── greece.py
│   ├── norway.py
│   └── spain.py
│
└── __init__.py

Wouldn't it be nice if we could copy this output and use it to generate the same file tree on our local machine?

That's the point of untree.

Installation

untree is a command-line utility. To install it globally, run:

pip install untree

Usage

untree [-s schema_file] -o output_dir

Examples

Paste text right into untree

Copy the tree output from a website, document or terminal and paste it right into untree.

# we don't pass a schema file flag here, so it waits for us to enter the schema directly.
# press CTRL-D to signal the end of the text.

$ untree -o /path/to/output/dir
world/
│
├── africa/
│   ├── __init__.py
│   └── zimbabwe.py
│
├── europe/
│   ├── __init__.py
│   ├── greece.py
│   ├── norway.py
│   └── spain.py
│
└── __init__.py

Read schema file into untree stdin

# pipe the output of tree directly into untree
$ untree -o /path/to/output/dir < schema.txt

Pipe data into untree via stdin

# pipe the output of tree directly into untree
$ tree -F --noreport /path/to/src/dir | untree -o /path/to/output/dir

Using a schema file

$ untree -o /path/to/output/dir -s schema.txt

Input Specification

untree is designed specifically to accept tree output as its input. However, the most basic invocation of tree produces output that, for our purposes, is ambiguous and extraneous. Therefore, the untree spec requires a slightly more specific invocation of tree:

tree -F --noreport <directory name>'
  • The -F flag adds a trailing slash after directory names to distinguish them from regular files.
  • The --noreport flag suppresses the tree command's concluding summary.

About

create a file tree from tree output

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0