~japanoise/unfolder.pl

WHAT IF YOU COULD HAVE A PLAINTEXT FILE TO DESCRIBE A DIRECTORY TREE SAID NO ONE EVER
9817d2f3 — japanoise 2 years ago
Initial

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~japanoise/unfolder.pl
read/write
git@git.sr.ht:~japanoise/unfolder.pl

You can also use your local clone with git send-email.

#unfolder

Now and again I get out of bed and have an insane idea. Today the idea was "what if I made a program that unfolds text files in a simple format to create a directory hierarchy?" This is the result of that idea. Pure Perl insanity.

#folder files

The base idea is that any unmarked text gets blasted straight into the current file. You can specify the file with a filename directive like so:

=f= Filename

This will close the previous file and open a new with the given filename.

You might wish to put your files in directories. That's easy enough, use a directory directive:

=d= My Super Directory

You might wish to put clarifying comments in your file. You can do this with either the comment directive:

=c= Single-line comment. Won't go to the output file.

Or by toggling on multiline comments with the multiline directive:

=l=
Anything until the next =l= will not be printed.
Neat, huh?
=l=

Directives must start at the first character. They consist of any number of equals signs (=, ASCII 0x3d) followed by a letter specifying the directive, and at least one further equals sign. Spaces directly after the trailing equals sign will be ignored.

All IO happens on standard input, so if you have a folder file "folder.txt" the way to unfold it is to run unfolder.pl <folder.txt. Similarly, if you want to use the provided script to fold a directory structure: folder.pl myfile.txt mydir >folder.txt

#installation

Well, it's pure Perl, so if you have a UNIX-like environment, just copy the files to somewhere on your $PATH environment variable. Usually that includes /usr/local/bin, so that's as good a place as any:

ln -s $PWD/unfolder.pl /usr/local/bin
ln -s $PWD/folder.pl /usr/local/bin

If you're on Windows, you can conceivably do some trickery to get it working using your new-fangled clickymouse, but it's probably best to install Cygwin.

#copying

Licensed under the terms of the MIT license; see the file LICENSE.