Scriptlike v0.9.4 - Perl-like interpolated strings, full examples and more.
Nick Sabalausky via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Sep 22 13:18:47 PDT 2015
Big update to Scriptlike, v0.9.4:
https://github.com/Abscissa/scriptlike
Scriptlike is a library to help you write script-like programs in D.
The two highlights in this release are string interpolation and a full
set of examples in the documentation. Also of note are the new functions
removePath and tryRemovePath which can be used to delete files (like
remove) *or* directories (like rmdirRecurse).
Full changelog:
http://semitwist.com/scriptlike/changelog.html
=====================
String Interpolation:
=====================
https://github.com/Abscissa/scriptlike#string-interpolation
AFAICT, a string mixin is necessary to accomplish this in D, but
otherwise it works much like other languages:
--------------------------------------------
// Output: The number 21 doubled is 42!
int num = 21;
writeln(
mixin(interp!"The number ${num} doubled is ${num * 2}!")
);
--------------------------------------------
The interpolated sections are handled via std.conv.text(), so they
accept any type.
Bikeshedding requested! I'm not 100% sold on the name "interp" for this
long-term. Suggestions welcome.
=========
Examples:
=========
https://github.com/Abscissa/scriptlike
https://github.com/Abscissa/scriptlike/blob/master/USAGE.md
https://github.com/Abscissa/scriptlike/tree/master/examples
The homepage/readme now provides sample code demonstrating all of
Scriptlike's various features.
The second link above demonstrates suggested practices for how to use
Scriptlike in a D-based script.
And finally, all examples are included as actual runnable programs (all
automatically tested by "dub test", to ensure continued freshness).
======================
All changes in v0.9.4:
======================
- Fixed: Previous release broke the unittest script when dub test
support was added.
- Fixed: In echo mode, several functions would echo the wrong "try*" or
non-"try*" version. Ex: run echoed tryRun, and tryRename echoed rename.
- Fixed: Path and buildNormalizedPathFixed now convert back/forward
slashes to native on BOTH Windows and Posix, not just on Windows.
- Fixed: Some links within changelog and API reference were pointing to
the reference docs for Scriptlike's latest version, instead of staying
within the same documentation version. This made archived docs for
previous versions difficult to navigate.
- Enhancement: #17,#20: Added usage examples to readme.
- Enhancement: Add interp for interpolated strings:
string s = mixin( interp!"Value is ${variableOrExpression}" )
- Enhancement: Add removePath/tryRemovePath for deleting a path
regardless of whether it's a file or directory. (Calls remove for files
and rmdirRecurse for directories.)
- Enhancement: Add a Path-accepting overload of escapeShellArg for the
sake of generic code.
- Enhancement: When runCollect throws, the ErrorLevelException now
includes and displays the command's output (otherwise there'd be no way
to inspect the command's output for diagnostic purposes).
- Enhancement: Greatly extended and improved set of tests.
More information about the Digitalmars-d-announce
mailing list