gridscale / gscloud

The official command-line interface for the gridscale API
https://gridscale.io/
MIT License
16 stars 8 forks source link

Fix CommandWithoutConfig #149

Closed JanLukasGithub closed 2 years ago

JanLukasGithub commented 2 years ago

Uses rootCmd.Find(os.Args[1:]). Fixes #147

bkircher commented 2 years ago

This needs rebasing

bkircher commented 2 years ago

@JanLukasGithub Thanks! I'm OK to merge this as it is.

Unfortunately, CommandWithoutConfig needs to access rootCmd in some way, and because two packages can't import each other, this is the best I could come up with

Another option maybe to change the signature of NewRuntime from

func NewRuntime(conf Config, accountName string, commandWithoutConfig bool) (*Runtime, error)

to something like

func NewRuntime(account *AccountEntry) (*Runtime, error)

Because, that runtime thing only ever works on one single account entry (or none at all, in which case entry would be nil) and does not necessarily need all the other accounts. If it would need those it could look like

func NewRuntime(conf Config, account *AccountEntry) (*Runtime, error)