Dan Anglin
55b93c6586
Move all executors to the internal folder package. This PR also comes with additional breaking changes. Changes: - refactor: move all executors to the internal/executor package. - refactor: update naming patterns for constants, variables, custom types, etc. - fix(breaking): renamed the update command to edit. - fix(breaking): update the flags for the switch command to make it more generic. - fix(breaking): renamed the show-account-relationship flag to show-relationship. - fix: update the print message from the whoami command.
36 lines
749 B
Go
36 lines
749 B
Go
package executor
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
|
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/config"
|
|
)
|
|
|
|
type WhoAmIExecutor struct {
|
|
*flag.FlagSet
|
|
|
|
topLevelFlags TopLevelFlags
|
|
}
|
|
|
|
func NewWhoAmIExecutor(tlf TopLevelFlags, name, summary string) *WhoAmIExecutor {
|
|
whoExe := WhoAmIExecutor{
|
|
FlagSet: flag.NewFlagSet(name, flag.ExitOnError),
|
|
topLevelFlags: tlf,
|
|
}
|
|
|
|
whoExe.Usage = commandUsageFunc(name, summary, whoExe.FlagSet)
|
|
|
|
return &whoExe
|
|
}
|
|
|
|
func (c *WhoAmIExecutor) Execute() error {
|
|
config, err := config.NewCredentialsConfigFromFile(c.topLevelFlags.ConfigDir)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to load the credential config; %w", err)
|
|
}
|
|
|
|
fmt.Printf("You are logged in as %q.\n", config.CurrentAccount)
|
|
|
|
return nil
|
|
}
|