kapitancho/walnut-lang-cli-adapter

There is no license information available for the latest version (0.0.6) of this package.

0.0.6 2024-04-09 22:02 UTC

This package is not auto-updated.

Last update: 2024-10-23 00:33:50 UTC


README

A small adapter for performing CLI calls to Walnut language code.

Installation

To install the latest version, use the following command:

$ composer require kapitancho/walnut-lang-cli-adapter

Usage

module demo-cli:

calc = ^Array<String> => Result<Integer, Any> ::
    ?noError(?noError(#->item(0))->asInteger) +
    ?noError(?noError(#->item(1))->asInteger);

main = ^Array<String> => String :: {
    s = calc(#);
    ?whenTypeOf(s) is {
        type{Integer}: s->asString,
        ~: 'Invalid parameters'
    }
};
php -f cli.php demo-cli 1 2
# Output: 3
php -f cli.php demo-cli 3 cats
# Output: Invalid parameters

Examples

You can browse the examples repository.