#__Quick question to all Module

1 messages ยท Page 1 of 1 (latest)

rotund sorrel
#

I may not be following the question entirely, but if you are generating example code then dag.Bats().WithSource is the correct one that users would actually need to write it they depend on the bats module, so we should go with that in that case I think

somber mason
#

Just to share the thought process behind the API I designed for that (and all of my modules):

There are two interfaces that users meet when using Dagger:

  • CLI
  • Code

For the CLI I find it more comfortable to use the high level Run function and pass the source directory as an argument to that.

Whereas when I call the module from code, I prefer using WithSource, because method chaining feels better than passing in an unbound amount of arguments.

WithSource also creates a more defensive style API that doesn't allow you to set a source directory for example.

So I'd say for the shell the high level functions are preferred, for SDK method chaining.

#

BTW it would be great to see documentation for constructors as well. I moved some of the method chaining logic to constructors and it simplified my modules a lot.

warm sleet
# somber mason Just to share the thought process behind the API I designed for that (and all of...

Thanks, very insightful ๐Ÿ™ Btw, I've been playing with your latest go module, and I get this error:

dagger call -m "github.com/sagikazarmark/daggerverse/go@main" --help                                

โœ˜ load call ERROR [0.91s]
โ”œ [0.52s] loading module
โ”œ [0.39s] loading objects
โ”ƒ Error: unsupported object type "CacheVolume" for flag: mod-cache                                                                                                           
โ”ƒ Call a module function and print the result.                        

dagger version
dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64

somber mason
#

Oh, that's interesting. I'll look into it, thanks!

#

I have e2e tests for my modules, but not for calling them from the CLI.

#

I assumed all IDable resources can be used from the CLI as well

#

Huge ๐Ÿ‘ for replacing the GH logo with a button labeled "source code"