3 ms·
A lot of this is already in marcel. A command run from the command line is a pipeline, e.g. list files recursively and output (path, filesize): ls -fr | (f
by geophile 3y ago
A lot of this is already in marcel. A command run from the command line is a pipeline, e.g. list files recursively and output (path, filesize):
ls -fr | (f: (f, f.size))
But now limit the command to .py files:
ls -fr | select (f: f.suffix == '.py') | (f: (f, f.size))
Also, just look at files changed in the past day:
ls -fr | select (f: f.suffix == '.py') | select (f: now() - f.mtime < days(1)) | (f: (f, f.size))
Those selects can be abstracted. They can be turned into their own parameterized pipelines, and assigned to variables. Here is a pipeline to filter files by a given extension:
ext = (| e: select (f: f.suffix == '.' + e) |)
And for files changed in the last d days:
recent = (| d: select (f: now() - f.mtime < days(int(d))) |)
So the original pipeline becomes:
ls -fr | ext py | recent 1 | (f: (f, f.size))