You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can introduce custom helper types for some of the bigger sub-commands (e.g. k6 run, k6 cloud, etc.) that split apart these monstrosities and flatten then 🎉 Something like this:
Hmm I had a thought that if globalState was exported and moved to another module (it doesn't really need to be in cmd/ anyway 🤷♂️), it would be super easy to allow xk6 extensions to add k6 sub-commands 🤔 Given the cobra architecture, it will even be easy to allow them to mess (e.g. add flags) with other sub-commands...
Still not sure if that is a good or a bad idea though 😅 And even if it's a good idea, it should probably wait for the configuration refactoring (#883), so we don't lock ourselves in the current bad state.
Now that #2410 and #2412 introduce a unified way of constructing
*cobra.Command
sub-commands:k6/cmd/root.go
Lines 242 to 246 in e4241ca
Instead of having functions that are hundreds of lines of code and starting indented 3 levels deep:
k6/cmd/run.go
Lines 80 to 83 in e4241ca
We can introduce custom helper types for some of the bigger sub-commands (e.g.
k6 run
,k6 cloud
, etc.) that split apart these monstrosities and flatten then 🎉 Something like this:Tons of benefits:
struct
can hold state, if needs bek6/cmd/archive.go
Line 29 in e4241ca
k6/cmd/cloud.go
Lines 49 to 50 in e4241ca
k6/cmd/inspect.go
Line 82 in e4241ca
k6/cmd/cloud.go
Line 330 in e4241ca
k6/cmd/run.go
Line 341 in e4241ca
The text was updated successfully, but these errors were encountered: