#Imagine a I have a function called `cli`
1 messages ยท Page 1 of 1 (latest)
Here is a concrete example
@function
def run(self, cmd: str = "--version") -> dagger.Container:
return (
self.base().with_exec(["sh", "-c", f"python {cmd}"])
)
I want to call run from the CLI but add a new directory before executing the command inside.
@slow sphinx yeah for sure we could, but the whole idea here is to create a simple proxy for a CLI as a starting point before implementing each command.
What I do in this case is set self.container in the constructor and use that as the base.
I basically want to do something before with_exec via the CLI
sorry I am not following ๐ฆ
Once you chain core functions in the CLI you can't chain from your module since those functions don't know about your module.
Yeah exactly
So it seems like its not possible or am I missing somethign obvious again? ๐
You need to encode what you need in a function in your module
Not possible to have a custom function after a core function
got it -- it feels like if we wanted to create a simple "cli proxy" function then it would probably make more sense to return a container having the cli and do everything else with chaining -- so
dagger call run with-directory with-exec
Maybe a tiny bit more context will help, the goal is to create a "minimally useful module" that wraps an open source CLI.
self.base().with_exec(["sh", "-c", f"$CLI {cmd}"])
(replace $CLI with your favorite CLI)
something like this works perfect if you just have simple string args, but as soon as you need to do something more complex, like passing a file or directory then it becomes more challenging.
Yes, ideally we have a function that does the right thing, but for a CLI with dozens or hundreds of functions this means we would need to reimplement all of them and I am trying to think about the simplest possible solution.
hopefully the use case I am talking about makes sense.
I think what you're looking for is basically what Solomon's core module does https://daggerverse.dev/mod/github.com/shykes/daggerverse/core
Im not sure I follow @candid patrol - can you give me an example of what you mean?