ANN: Newt - command-line template instantiation tool & library

I'm happy to announce Newt: a trivial tool for creating boilerplate. I frequently need to create projects with slight customizations -- I have a particular layout for cabal projects, and make files for LaTeX papers, etc... However, there are often fields that need to be updated in many places. (At times, even file or directory names need changed.) Newt makes this trivial. My objective was to provide a tool that allows you to very quickly take a project, mark the portions that must change with angle brackets, and use that as a source for myriad derivations of that project, or share the project for others to create their own instances. Newt scans the input (either a file, directory or stdin) for tags marked with "<<<tagName>>>" [1], then replaces those entries with values specified on the command line, producing either a new file, modifying the input template in place (--inplace), writing to stdout, or writing to a directory. A newt template for a cabal project is available on github: - http://github.com/creswick/Newt/tree/master/tests/testFiles/dirTemplates/cab... Newt is available on hackage[2], and the source is hosted on github[3]. The readme provides more details and examples: - http://github.com/creswick/Newt/blob/master/README.md --Rogan [1] The tag syntax can be changed with command-line flags, or by creating an instance of the Tag typeclass. See --help. [2] http://hackage.haskell.org/package/newt [3] http://github.com/creswick/Newt/

On Sun, 8 May 2011 16:23:59 -0700
Rogan Creswick
Newt scans the input (either a file, directory or stdin) for tags marked with "<<<tagName>>>" [1], then replaces those entries with values specified on the command line, producing either a new file, modifying the input template in place (--inplace), writing to stdout, or writing to a directory.
This is a useful tool ! I would like to suggest allowing customization of the syntax to indicate a tag, e.g. {# #} instead of <<< >>> (You just knew someone was going to say that, right ? :-) I only mention this in the hopes that it still early enough for you to write the code in such a way to allow this even if you don't implement it right away. Brian

2011/5/9
On Sun, 8 May 2011 16:23:59 -0700 Rogan Creswick
wrote: Newt scans the input (either a file, directory or stdin) for tags marked with "<<<tagName>>>" [1], then replaces those entries with values specified on the command line, producing either a new file, modifying the input template in place (--inplace), writing to stdout, or writing to a directory.
This is a useful tool !
I would like to suggest allowing customization of the syntax to indicate a tag, e.g. {# #} instead of <<< >>> (You just knew someone was going to say that, right ? :-)
Hello, Did you see his [1] footnote in his mail? Cheers, Thu

On Sun, May 8, 2011 at 10:38 PM,
This is a useful tool !
I'm glad you think so too!
I would like to suggest allowing customization of the syntax to indicate a tag, e.g. {# #} instead of <<< >>> (You just knew someone was going to say that, right ? :-)
Indeed :) The tag syntax is controlled by two command-line flags: --prefix=... and --suffix=... It can be difficult to get the desired strings past both the shell and the regular expression compiler (although that last bit is changing... Josh Hoyt sent a patch that switches to basic string inspection, which should make this much simpler to use.) --Rogan
I only mention this in the hopes that it still early enough for you to write the code in such a way to allow this even if you don't implement it right away.
Brian
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, May 9, 2011 at 8:25 AM, Rogan Creswick
Indeed :) The tag syntax is controlled by two command-line flags: --prefix=... and --suffix=...
It can be difficult to get the desired strings past both the shell and the regular expression compiler (although that last bit is changing... Josh Hoyt sent a patch that switches to basic string inspection, which should make this much simpler to use.)
I've just released newt-0.0.3.0, which has the patch from Josh (It also uses a much nicer command-line syntaxt - it's backwards compatible, but you can leave off the --source / --dest specifiers now.) With Josh's patch, things like this "just work": $ newt --prefix="***" --suffix="***" You can also look at the configuration structure with --verbose to help debug problems with these flags: $ newt --list <some input file> --prefix="***" --suffix="***" --verbose Using configuration: Config {source = Just "tests/testFiles/simpleTest/alternate1.txt", dest = Nothing, rawTable = [], list = True, inplace = False, prefix = Just "***", suffix = Just "***", verb = Loud} This release also fixes a pretty important bug relating to binary files... you couldn't have any binary content in your templates -- 0.0.3.0 doesn't try to perform template replacements on binary files now (which failed immediately in hGetContents in the previous version). Feedback / suggestions are always appreciated :) Thanks! --Rogan
participants (3)
-
briand@aracnet.com
-
Rogan Creswick
-
Vo Minh Thu