GithubHelp home page GithubHelp logo

abscissa / scriptlike Goto Github PK

View Code? Open in Web Editor NEW
93.0 93.0 10.0 708 KB

Utility library to help you write script-like programs in D

License: Other

Shell 1.03% D 98.06% Batchfile 0.86% Makefile 0.05%

scriptlike's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scriptlike's Issues

Access to standard Phobos function hampered

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

ASynchronous Future Returning Variant of run

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

userInput for passwords

Would be great to have a version of userInput that masked what was typed, e.g. using "read -s"

Cross-platform way to run a program that's in the current directory.

./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`);

Compile error in gdc

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

dirEntries wrappers for different span modes

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

Documentation: Lack of usage patterns, example scripts, and user documentation.

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

DDOC-ify doc comments

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.

Deprecation warnings

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

Optional callback sink for command echoing

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.

Add simple example script

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

Unable to build docs of own project with DUB

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.

The Fail Exception should take a return code

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

Path("~") should extend to home directory

  • Path("~") -> Path("/home/user")
  • Path("~/.config/foo") -> Path("/home/user/.config/foo")
  • Path("~user2") -> Path("/home/user2")
  • Path("~custom_home_user") -> Path("/var/www")

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

"Dry run" support

Similar to scriptlikeTraceCommands, Scriptlike should offer help in creating "dry run" modes.

deprecation warnings running single-file example

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

deprecation warnings in compiling

$ 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;'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.