~autumnull/treecat

serialize a directory into a tree diagram, and vice versa
7 days ago

53ad812 update for Hare 0.24.2

7 days ago

#Treecat

Serialize a directory to a tree diagram, and vice versa.

Note: this program and parts of this README are not screen-reader friendly.

A pen drawing, two cats. One is sitting on the ground, mewing concernedly at the other, who is stuck up on the branch of a tree overlooking with their head upside-down in perplexity. In the words of the artist: mew?

#Installation

Requires a Hare install, scdoc(1) to build the man page, and probably haredo(1), or else you can try building it manually with hare.

git clone https://git.sr.ht/~autumnull/treecat
cd treecat
haredo
haredo test
sudo haredo install
# sudo haredo uninstall

#Usage

Below is a rough guide to treecat's usage. See the man page for detailed information.

manual/
├── aperitif.md:
│ Treecat serializes a filetree to a tree diagram, and vice versa.
│ 
│ To demonstrate what that means, this manual is an example of treecat's output.
│ You can turn this manual into a filetree using `treecat -r`, and turn that
│ filetree back into this manual using `treecat`.
│ 
├── basics/
│   ├── description.md:
│   │ Treecat is an amalgamation of `tree(1)` and `cat(1)`, with the added bonus that
│   │ it can reconstruct its output back into the original filetree.
│   │ 
│   ├── use-cases.md:
│   │ - quickly see the contents of a directory
│   │ - display a filetree structure for use in documentation (so that a user can
│   │  then easily reconstruct the directory using `treecat -r`)
│   │ - sending projects to friends to view and potentially reconstruct
│   │ - converting your home directory into one big text file to save disk space
│   │ - any other situation where you might want to display a directory and its
│   │  contents in a potentially reconstructible way.
│   └ 
├── binary/
│   ├── doc.md:
│   │ Files that are not valid UTF-8 will be printed out as a hexdump instead. The
│   │ marker '#' is used after the filename to indicate that it is a hexdump of a
│   │ binary file, rather than a file that looks like a hexdump anyway.
│   │ 
│   │ See the difference:
│   │ 
│   ├── pusheen.pbm#
│   │ 5034 0a32 3320 3138 0a10 2000 2850 002f
│   │ d00c 6698 1240 0812 c00f 8e92 454a 8505
│   │ 3e80 0014 8000 1480 0008 8000 0880 0008
│   │ c000 1860 0030 3683 6016 fb40 198c c0
│   ├── pusheen.pbm.hex:
│   │ 5034 0a32 3320 3138 0a10 2000 2850 002f
│   │ d00c 6698 1240 0812 c00f 8e92 454a 8505
│   │ 3e80 0014 8000 1480 0008 c000 08c0 0008
│   └ c000 1860 0030 3683 6016 fb40 198c c0
├── executables/
│   ├── doc.md:
│   │ If a file is executable (specifically, if it has the u+x permission), treecat
│   │ will store this information. Note: no other file permissions are stored, since
│   │ treecat is designed to be simple.
│   │ 
│   │ Names of executable binary files will be followed by a '*', and executable text
│   │ files will be followed by a '+'. For example:
│   │ 
│   ├── hello.elf*
│   │ 7f45 4c46 0101 0100 0000 0000 0000 0000
│   │ 0200 0300 0100 0000 6000 0008 4000 0000
│   │ d000 0000 0000 0000 3400 2000 0100 2800
│   │ 0400 0300 0000 0000 0000 0000 0000 0000
│   │ 0100 0000 0000 0000 0000 0008 0000 0008
│   │ b000 0000 b000 0000 0500 0000 0000 0000
│   │ b990 0000 08ba 1300 0000 bb01 0000 00b8
│   │ 0400 0000 cd80 bb01 0000 00b8 0100 0000
│   │ cd80 0000 0000 0000 0000 0000 0000 0000
│   │ 6865 6c6c 6f2c 2074 7265 6563 6174 2120
│   │ 3a33 0a00 0000 0000 0000 0000 0000 0000
│   │ 002e 7368 7374 7274 6162 002e 7465 7874
│   │ 002e 726f 6461 7461 0000 0000 0000 0000
│   │ 0000 0000 0000 0000 0000 0000 0000 0000
│   │ 0000 0000 0000 0000 0000 0000 0000 0000
│   │ 0000 0000 0000 0000 0b00 0000 0100 0000
│   │ 0600 0000 6000 0008 6000 0000 2200 0000
│   │ 0000 0000 0000 0000 0000 0000 0000 0000
│   │ 1100 0000 0100 0000 0200 0000 9000 0008
│   │ 9000 0000 1300 0000 0000 0000 0000 0000
│   │ 0000 0000 0000 0000 0100 0000 0300 0000
│   │ 0000 0000 0000 0000 b000 0000 1900 0000
│   │ 0000 0000 0000 0000 0000 0000 0000 0000
│   ├── print+
│   │ #!/bin/sh
│   │ # print - prints out the contents of a file
│   │ 
│   │ if [ $# -ne 1 ]
│   │ then
│   │     echo "Usage: $0 <file>"
│   │     exit 1
│   │ else
│   │     cat $1
│   │ fi
│   └ 
└── symlinks/
    ├── cat@
    │   └╶╶ ../executables/print
    ├── doc.md:
    │ Treecat stores symlinks with the file marker '@'. The target of the symlink is
    │ shown in a dashed branch below the filename, as shown above.
    └ 

#Contributing

Please send patches and bug reports to ~autumnull/treecat-dev@lists.sr.ht.