On Tuesday, 11 February 2014 at 11:38:06 UTC, Nick Sabalausky wrote:
I've released a little one-module utility, Scriptlike, to help simplify writing shell script-like programs in D:

  https://github.com/Abscissa/scriptlike


It looks like you've covered a lot of the short comings for doing some cmdln scripting. It also sounds like it would fit right into what I was doing (I hand only covered the user input portion) https://github.com/JesseKPhillips/JPDLibs/tree/cmdln (I really probably should move it into its own project, maybe I should instead submit mine to yours? Though I use Boost License).

[OT] I also want to thank those behind std.process, std.path, and std.algorithms these things have been really awesome and I use heavily (great improvements).

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.

Personally I've found the new std.path makes this much easier, I'm not user how you can address paths-with-spaces as this depends on who you call, internally I don't need to worry. But maybe this simplifies it more and is still worth it.

- 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

Command echoing, and dry run are both valuable.

- 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.

This is my biggest gripe with the current available functions!

- 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.)

Aside from the bug, I don't understand what this provides over "execute."

- 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().)

I've just been using exceptions, Fail should take a return code too.

Reply via email to