geophile / marcel

A modern shell
https://marceltheshell.org
GNU General Public License v3.0
338 stars 13 forks source link

Example request: arguments #19

Closed rhn closed 1 year ago

rhn commented 1 year ago

The pipeline example shows how to use data items passed by the previous part of the pipeline, but doesn't allow specifying arguments:

$ l = (|ls|)
$ l foo
Wrong number of arguments for pipeline l = ls

This makes creating custom commands limited.

geophile commented 1 year ago

Arguments to pipelines need to be declared. Try this:

l = (| dir: ls (dir) |)
l foo

dir: declares the argument. "ls dir" won't work, that looks for a directory named "dir". "ls (dir)" causes the value of the dir variable to be returned, which is "foo" in that invocation on the second line.