Repository navigation
Support for constructors in modules - #6135
Conversation
|
@helderco the updates needed to our cobra setup are not incredibly obvious; I've poked around a bit but wondering if you have any pointers before I delve deeper. Basically, we need to add module-specific flags above any subcommands, e.g. If I add those flags here then I can get them to show up in the output of But then when I try to actually use the flag I just get an error very quickly: I think the problem is that we parse flags in the PreRun here but we ideally shouldn't be parsing them until later now. My default next path to try would be to refactor the But let me know if that makes sense to you too or if you see any better approaches 🙂 |
|
@sipsma I think we can just re-parse the flags for |
|
@helderco okay eventually figured out the right incantation, the real key part was allowing unknown flags in this specific way here: 7fce686#diff-711069b715d2ad35d6eb28753227a571e815b68256d043a8d4337a9593c2a7daR265 Otherwise we hit a catch-22 where we can't parse global flags related to the TUI (i.e. But allowing unknown flags there fixes it. We still re-parse later as you suggested so if anything is actually not recognized we will eventually error out, just a little bit down the line. |
|
Not sure if this is a pre-existing issue, but just noticed while testing manually that if you have a broken module (syntax error, whatever) and try to run I think in this situation it makes sense to show both; we can't show the full --help output since we can't load all the constructor flags, but we can at least show you the base --help output without the module specific subcommands/flags |
There was a problem hiding this comment.
We could make some fragments in this query to make it easier to manage 🙂
There was a problem hiding this comment.
Agree this is reaching the tipping point, but I'm actually not sure off the top of my head how you actually do that with our client... would we just include the fragments in this big blob and then reference them in the query? I have not yet touched fragments in graphql somehow, probably time to :-)
|
This is noice, I plan on adding Python support tomorrow. 🙂 |
Yeah, I agree. Feels reasonable, in line with empty ParentName for module registration. No immediate improvement comes to mind. |
Fixed this here: b746ecd |
This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
|
I have a working Python implementation, just need to cleanup and fit the integration test next to Go. One of those cases with different module sources but same testing code. |
helderco
left a comment
There was a problem hiding this comment.
I wasn't able to finish Python today but I can do it in a follow up so this isn't blocked.
Oh no worries at all, totally fine as a follow up. Thank you so much for the help! |
* chore: rename function.graphqls to typedef.graphqls This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]> * WIP: support for constructors in modules Signed-off-by: Erik Sipsma <[email protected]> * cleanup go sdk todos Signed-off-by: Erik Sipsma <[email protected]> * cleanup core todos Signed-off-by: Erik Sipsma <[email protected]> * add support for constructor flags to CLI Signed-off-by: Erik Sipsma <[email protected]> * add integ tests Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback around flag validation Signed-off-by: Erik Sipsma <[email protected]> * handle dagger call --help on broken module Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback: move flag re-parsing to common func Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]> Signed-off-by: Christian Schlatter <[email protected]>
* chore: rename function.graphqls to typedef.graphqls This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]> * WIP: support for constructors in modules Signed-off-by: Erik Sipsma <[email protected]> * cleanup go sdk todos Signed-off-by: Erik Sipsma <[email protected]> * cleanup core todos Signed-off-by: Erik Sipsma <[email protected]> * add support for constructor flags to CLI Signed-off-by: Erik Sipsma <[email protected]> * add integ tests Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback around flag validation Signed-off-by: Erik Sipsma <[email protected]> * handle dagger call --help on broken module Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback: move flag re-parsing to common func Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
* chore: rename function.graphqls to typedef.graphqls This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]> * WIP: support for constructors in modules Signed-off-by: Erik Sipsma <[email protected]> * cleanup go sdk todos Signed-off-by: Erik Sipsma <[email protected]> * cleanup core todos Signed-off-by: Erik Sipsma <[email protected]> * add support for constructor flags to CLI Signed-off-by: Erik Sipsma <[email protected]> * add integ tests Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback around flag validation Signed-off-by: Erik Sipsma <[email protected]> * handle dagger call --help on broken module Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback: move flag re-parsing to common func Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
* chore: rename function.graphqls to typedef.graphqls This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]> * WIP: support for constructors in modules Signed-off-by: Erik Sipsma <[email protected]> * cleanup go sdk todos Signed-off-by: Erik Sipsma <[email protected]> * cleanup core todos Signed-off-by: Erik Sipsma <[email protected]> * add support for constructor flags to CLI Signed-off-by: Erik Sipsma <[email protected]> * add integ tests Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback around flag validation Signed-off-by: Erik Sipsma <[email protected]> * handle dagger call --help on broken module Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback: move flag re-parsing to common func Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
* chore: rename function.graphqls to typedef.graphqls This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]> * WIP: support for constructors in modules Signed-off-by: Erik Sipsma <[email protected]> * cleanup go sdk todos Signed-off-by: Erik Sipsma <[email protected]> * cleanup core todos Signed-off-by: Erik Sipsma <[email protected]> * add support for constructor flags to CLI Signed-off-by: Erik Sipsma <[email protected]> * add integ tests Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback around flag validation Signed-off-by: Erik Sipsma <[email protected]> * handle dagger call --help on broken module Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback: move flag re-parsing to common func Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
* chore: rename function.graphqls to typedef.graphqls This file used to just have Function in it a while back, but has since expanded to be all typedefs; Function isn't even the "main point" anymore. Renaming to fix the confusion before it grows deeper. Signed-off-by: Erik Sipsma <[email protected]> * WIP: support for constructors in modules Signed-off-by: Erik Sipsma <[email protected]> * cleanup go sdk todos Signed-off-by: Erik Sipsma <[email protected]> * cleanup core todos Signed-off-by: Erik Sipsma <[email protected]> * add support for constructor flags to CLI Signed-off-by: Erik Sipsma <[email protected]> * add integ tests Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback around flag validation Signed-off-by: Erik Sipsma <[email protected]> * handle dagger call --help on broken module Signed-off-by: Erik Sipsma <[email protected]> * address helder feedback: move flag re-parsing to common func Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
Closes #6132
dagger call echoon that module now returnsdefaultfooanddagger call --foo=abc echonow returnsabc.In general constructors can accept the same kinds of arguments as any other function, e.g. this is also valid:
Overall idea:
WithConstructoris an api onTypeDefTypeDefrather thanModulethough because I want to leave open the option to allow this on other objects in the future. If we ever support the notion of importing selected objects from other modules (rather than just all or nothing) then this could make sense. If we never go down that route, no harm done.ParentNameto the object and leaving theFunctionNameblank.TODOs: