abscissa / scriptlike Goto Github PK
View Code? Open in Web Editor NEWUtility library to help you write script-like programs in D
License: Other
Utility library to help you write script-like programs in D
License: Other
Copy/rename/remove/rmdir should take optional range of paths (such as from dirEntries) as "from".
This is mostly in, but it's disabled and untested as it's blocked by DMD issue #12112
Need a function to delete an entire directory tree. IIRC, rmdir only deletes empty directories.
Copy and rename should accept directories as the destination.
Some changes made after 0.7.0 have caused standard Phobos functions to be inaccessible:
import scriptlike;
void main() {
exists("MyFilename.txt");
}
Error: function scriptlike.file.wrappers.exists (const(Path) name) is not callable using argument types (string)
This has also happened with other std.file/std.path functions like dirEntries and baseName...
I'm missing an asynchronous variant of tryRun
that returns a Future
of a structure containing the process exist status along with outputs to stdout and stderr if any. asyncRun
is probably a good name :)
Would be great to have a version of userInput that masked what was typed, e.g. using "read -s"
Please add support for latest DMD 2.086.0
./somebin ...
works everywhere but windows. Omitting the ./
only works on windows. Need to figure out a good way so scripts don't need awful garbage like:
run(`.`~dirSeparator~`mytool --args`);
or
run(buildPath(`.`, `mytool`)~` --args`);
or
version(Windows)
run(`mytool --args`);
else
run(`./mytool --args`);
Need to update "Disambiguating write and write" section on readme to correctly handle the newly enforced import lookup rules in latest DMD.
A "try" version of it should be usable on Windows even if it's only a no-op there.
I'm running gdc 4.9.2 on Debian Jessie. I used dub to fetch scriptlike 0.9.3. When I ran dub run scriptlike, it gave the following error:
file/wrappers.d:431: error: template scriptlike.file.wrappers.slurp(Types...)(Path filename, in string format) conflicts with alias scriptlike.file.wrappers.slurp at file/wrappers.d:63
Commenting out this line in file/wrappers.d is my work-around:
alias slurp = std.file.slurp; ///ditto
However, some new errors then arise:
scriptlike/process.d:165: error: mismatched function return type inference of ProcessOutput and Tuple!(int, "status", string, "output")
scriptlike/process.d:165: error: cannot implicitly convert expression (executeShell(command, null, cast(Config)0, 18446744073709551615LU)) of type ProcessOutput to Tuple!(int, "status", string, "output")
Less verbose, easier to remember. Include proper deprecation path, of course.
While this would be inappropriate for Phobos as it's against Phobos's rule of "no unnecessary wrappers", having some dirEntries wrappers for the different span modes would nicely meet scriptlike's charter of "make script-like stuff quick & easy".
Note dlang/dub#907
(If possible) Need a function to wrap thisExePath that returns FILE_FULL_PATH insetad of thisExePath when appropriate.
I know, that that can be inferred from the unittests, but it is time consuming: they are scattered throughout the code and not necessarily examples of typical/intended usage patterns.
Could you write some simple D scripts as examples of the intended usage?
Sometimes, great applications start as a shell script. And D is a perfect language to let the shell script evolve into something big and complex. I wish, that the authors of Puppet Configuration Management had started writing it in D...
For a simple lone symbol, interp should allow simplifying this...
auto foo = 42;
auto str = mixin(interp!"Value is ${foo} now");
...down to...
auto foo = 42;
auto str = mixin(interp!"Value is $foo now");
...and getcwd
(unavoidably) resolves symlinks automatically (unlike the pwd
shell command).
Fixing this properly will require #21.
The doc comments mostly ignore DDOC right now. Consequently, the API docs have some...crappiness. This should be improved, including adding a menu of all modules to each page.
/home/denizzz/.dub/packages/scriptlike-0.9.6/scriptlike/src/scriptlike/interact.d(88): Deprecation: Implicit string concatenation is deprecated, use "Value required, " ~ "cannot continue operation." instead
/home/denizzz/.dub/packages/scriptlike-0.9.6/scriptlike/src/scriptlike/interact.d(88): Deprecation: Implicit string concatenation is deprecated, use "Value required, " ~ "cannot continue operation." instead
/home/denizzz/.dub/packages/scriptlike-0.9.6/scriptlike/src/scriptlike/fail.d(36): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
Need to use versioning to make sure non-Windows functions appear in docs when docs are built on Windows, and non-Posix funcs when built on Posix, etc.
Setting scriptlikeTraceCommands to true will echo commands to stdout, but there should be a way to override using stdout and allow to user to provide an OutputRange sink instead.
API docs need, at the very least, a stylesheet.
It might be useful to add a basic example of how to use this in a script. For example I used
dub fetch scriptlike
and then you can build an executable script like so:
#!/usr/bin/rdmd -I/path/to/home/.dub/packages/scriptlike-0.9.2/src/
import scriptlike;
void main()
{
"Hello world!".writeln;
}
You of course need to make it executable as well
chmod +x myscript.d
./myscript.d
When attempting to use $ dub build --build=docs on a project which depends on scriptlike, the compiler errors with
package.d(45,24): Error: module changelog is in file 'changelog.d' which can not be read
This is probably more an issue with DUB, but maybe a different choice could be made within scriptlike for its doc generation.
After #4 is implemented, a good set of convenience wrappers would be copyGlob/renameGlob/removeGlob/rmdirGlob
to simplify things like copy(path.dirEntires(...), ...)
It can be very important to specify the error of a program run, so fail should easily specify what that code should be. Maybe even type check that it is an enum to force users to name their errors :)
see std.path.expandTilde and reading /etc/passwd or using the functions from the core.sys module thingy
on windows its a bit more complicated
(Relies on #35)
Need versions of runShell that take args as array or maybe range.
Similar to scriptlikeTraceCommands
, Scriptlike should offer help in creating "dry run" modes.
...and to make the changelog source easier to find.
../../../../.dub/packages/scriptlike-0.10.2/scriptlike/src/scriptlike/path/extras.d(25,8): Deprecation: module `std.path` member osDefaultCaseSensitivity is not visible from module extras
../../../../.dub/packages/scriptlike-0.10.2/scriptlike/src/scriptlike/path/wrappers.d(26,15): Deprecation: module `std.path` member osDefaultCaseSensitivity is not visible from module wrappers
../../../../.dub/packages/scriptlike-0.10.2/scriptlike/src/scriptlike/interact.d(173,24): Deprecation: function `std.string.removechars!string.removechars` is deprecated - This function is obsolete and will be removed May 2018. See the docs for more details
../../../../.dub/packages/scriptlike-0.10.2/scriptlike/src/scriptlike/path/extras.d(25,8): Deprecation: module `std.path` member osDefaultCaseSensitivity is not visible from module extras
../../../../.dub/packages/scriptlike-0.10.2/scriptlike/src/scriptlike/path/wrappers.d(26,15): Deprecation: module `std.path` member osDefaultCaseSensitivity is not visible from module wrappers
$ dmd --version
DMD64 D Compiler v2.071.0
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
$ dub test
src/scriptlike/path/extras.d(36,2): Deprecation: constructor scriptlike.path.extras.Ext.this all parameters have default arguments, but structs cannot have default constructors.
src/scriptlike/path/extras.d(105,2): Deprecation: constructor scriptlike.path.extras.Path.this all parameters have default arguments, but structs cannot have default constructors.
src/scriptlike/core.d(345,27): Deprecation: module std.path is not accessible here, perhaps add 'static import std.path;'
src/scriptlike/core.d(346,7): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(352,13): Deprecation: module std.path is not accessible here, perhaps add 'static import std.path;'
src/scriptlike/core.d(337,14): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(372,9): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(374,10): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(375,8): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(377,8): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(368,14): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(407,32): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(426,19): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(444,19): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(463,19): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(407,32): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(426,19): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(444,19): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(463,19): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
src/scriptlike/core.d(407,32): Deprecation: module std.file is not accessible here, perhaps add 'static import std.file;'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.