// Copyright 2024 Matthew Rich . All rights reserved. package command import ( "errors" "fmt" ) var ( ErrInvalidCommandType error = errors.New("Invalid command type") ) type CommandType string const ( ExecCommand CommandType = "exec" ContainerCommand CommandType = "container" SSHCommand CommandType = "ssh" ) func (t CommandType) Validate() error { switch t { case ExecCommand, ContainerCommand, SSHCommand: return nil } return fmt.Errorf("%w: %s", ErrInvalidCommandType, t) } func (t CommandType) Provider(cmd *Command, value any) CommandProvider { switch t { case ContainerCommand: return NewContainerProvider(cmd, value) case SSHCommand: return NewSSHProvider(cmd, value) default: fallthrough case ExecCommand: return NewExecProvider(cmd, value) } return nil }