Scriptlike: New lib to aid in writing script-like programs
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Tue Feb 11 03:37:57 PST 2014
I've released a little one-module utility, Scriptlike, to help simplify
writing shell script-like programs in D:
https://github.com/Abscissa/scriptlike
Here's post outlining my motivations for this library (sorry, the CMS
I'm using ATM generates very long URLs):
http://semitwist.com/articles/article/view/scriptlike-shell-scripting-in-d-annoyances-and-a-library-solution
Current Features:
- A thin wrapper over std.path and std.file that provides a dedicated
Path type specifically designed for managing file paths in a simple,
reliable, cross-platform way. No more dealing with slashes,
paths-with-spaces, calling buildPath, normalizing, or getting paths
mixed up with ordinary strings.
- Optionally enable automatic command echoing (including shell commands,
changing/creating directories and
deleting/copying/moving/linking/renaming both directories and files) by
setting one simple flag: bool scriptlikeTraceCommands
- Most typical Phobos modules automatically imported. Who needs rows and
rows of standard lib imports for a mere script?
- Less-pedantic filesystem operations for when you don't care whether it
exists or not: existsAsFile, existsAsDir, existsAsSymlink, tryRename,
trySymlink, tryCopy, tryMkdir, tryMkdirRecurse, tryRmdir,
tryRmdirRecurse, tryRemove: All check whether the source path exists and
return WITHOUT throwing if there's nothing to do.
- One simple call, runShell, to run a shell command script-style (ie,
synchronously with forwarded stdout/in/err) from any working directory.
(Also automatically works around DMD #10863 without waiting for v2.066 -
BTW, thanks all involved who fixed that.)
- One simple function, fail(string msg), to help you exit with an error
message in an exception-safe way. (Does require some minor boilerplate
added to your main().)
More information about the Digitalmars-d-announce
mailing list