Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: allow calling core functions directly #7310

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

helderco
Copy link
Contributor

@helderco helderco commented May 7, 2024

Fixes #6947

Warning

This is based on other PRs so they can all be tested here together, but they need to be merged first, especially #7417. They're in their own commits so it's easier to review just the last one:

Can be run from anywhere as it doesn't require a module to load:

Screenshot 2024-05-20 at 18 47 41

Todo

@helderco helderco force-pushed the helder/oss-192-allow-calling-core-functions-from-the-cli branch from ea1d2ce to 797666b Compare May 20, 2024 17:30
@helderco helderco force-pushed the helder/oss-192-allow-calling-core-functions-from-the-cli branch from 797666b to 27589db Compare May 20, 2024 18:51
Most common reason for not being able to call a function is unsupported flags, but if there's unsupported return types as well, they should be added too.

This change excludes functions with **any** unsupported flag, however, maybe it’s best to do it only for required flags, and keep the function but skip adding the optional arguments that aren’t supported.

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This removes `sync` as a default selection for commands ending in a `Container`, `Directory` or `File`.

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
The `--help` flag is now global (interspersed). So the help will no longer be shown next to the command where it’s defined if there’s more to the right. It’s position in the chain no longer matters, it will be the same as adding it to the end. This was needed to look ahead and skip some validations while that flag wasn’t parsed yet, and while it was possible to preserve the previous behavior, making it global seems more consistent with CLI conventions, besides being simpler.

There's also some refactoring to make the logic easier to follow and encapsulate some responsibilities better in functions.

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>

# Conflicts:
#	cmd/dagger/functions.go
#	cmd/dagger/module.go
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
@helderco helderco force-pushed the helder/oss-192-allow-calling-core-functions-from-the-cli branch from 27589db to babaf87 Compare May 21, 2024 14:41
@helderco
Copy link
Contributor Author

Update: based on discussion in #6947, will need to make some changes:

- dagger -m- container
+ dagger -m container

Will check if what's in -m matches a field under Query first, and fallback to the usual module loading behavior if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow calling core functions from the CLI
1 participant