Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Introduce arguments to tasks #40

Closed
cassaundra opened this issue Jan 17, 2024 · 1 comment
Closed

Introduce arguments to tasks #40

cassaundra opened this issue Jan 17, 2024 · 1 comment
Labels
enhancement New feature or request nushell-engine Items relevant to the nushell engine
Milestone

Comments

@cassaundra
Copy link
Collaborator

Proposals

Proposed syntax would make def-tasks look more like normal defs:

def-task bundle-dist [--no-man, --opt-level: string] {
    if not $no_man {
        # ...
    }

    # ...
}

These arguments should be available in both the declaration and the run closures, and are set through depends invocations (e.g. depends bundle-dist --no-man) and quake calls (e.g. quake bundle-dist --no-man).

This would be the first first-class "configuration" feature added to the language. Since these arguments are strongly typed and made easily accessible via the command-line, this seems like an easy win.

Implementation details

The quake Engine::run would have an additional arguments field (probably just the raw list of arguments? or maybe something better typed) which it would apply to the target task.

This probably introduces some nushell parsing problems, but I think we can sidestep those we a few clever hacks. This might include some sort of syntactical pre-processor step, which could have rather complex implications (especially when trying to preserve source spans). In general though, we really want to keep the amount of "magic" happening low, so features like a post-eval REPL (see #9) are maximally useful.

We would also need to rethink how we keep track of tasks globally, since tasks called with different arguments may have different sources/artifacts, dependencies, and effective run implementations. This means internally we should keep track of tasks both as high-level constructs and as individual invocations. When exposing internal data to the user (e.g. via quake inspect or task names in logs), we should refer to task invocations, except in the case of quake inspect --list.

@cassaundra cassaundra added enhancement New feature or request nushell-engine Items relevant to the nushell engine labels Jan 17, 2024
@cassaundra cassaundra added this to the quake 0.1.0 milestone Jan 18, 2024
@cassaundra cassaundra mentioned this issue Jan 30, 2024
15 tasks
@cassaundra
Copy link
Collaborator Author

Implemented as part of #45.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request nushell-engine Items relevant to the nushell engine
Projects
None yet
Development

No branches or pull requests

1 participant