Dan Anglin
c04cd7e8a5
Changes: - moved the command names from main to the executor package. - moved the unknownCommandError to the executor package and renamed it to UnknownCommandError. - define the command summaries within the executor package. - replace the switch statement in main.run() with a hashmap for looking up the corresponding executor to the given command. - transformed BlockExecutor to BlockOrUnblockExecutor. - transformed FollowExecutor to FollowOrUnfollowExecutor. Additional fixes: - fixed flag for the version executor.
68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package executor
|
|
|
|
type FlagNotSetError struct {
|
|
flagText string
|
|
}
|
|
|
|
func (e FlagNotSetError) Error() string {
|
|
return "please use the required --" + e.flagText + " flag"
|
|
}
|
|
|
|
type UnsupportedTypeError struct {
|
|
resourceType string
|
|
}
|
|
|
|
func (e UnsupportedTypeError) Error() string {
|
|
return "'" + e.resourceType + "' is not supported for this operation"
|
|
}
|
|
|
|
type NoAccountSpecifiedError struct{}
|
|
|
|
func (e NoAccountSpecifiedError) Error() string {
|
|
return "no account specified in this request"
|
|
}
|
|
|
|
type UnsupportedAddOperationError struct {
|
|
ResourceType string
|
|
AddToResourceType string
|
|
}
|
|
|
|
func (e UnsupportedAddOperationError) Error() string {
|
|
return "adding '" + e.ResourceType + "' to '" + e.AddToResourceType + "' is not supported"
|
|
}
|
|
|
|
type UnsupportedRemoveOperationError struct {
|
|
ResourceType string
|
|
RemoveFromResourceType string
|
|
}
|
|
|
|
func (e UnsupportedRemoveOperationError) Error() string {
|
|
return "removing '" + e.ResourceType + "' from '" + e.RemoveFromResourceType + "' is not supported"
|
|
}
|
|
|
|
type EmptyContentError struct {
|
|
ResourceType string
|
|
Hint string
|
|
}
|
|
|
|
func (e EmptyContentError) Error() string {
|
|
message := "the content of this " + e.ResourceType + " should not be empty"
|
|
|
|
if e.Hint != "" {
|
|
message += ", " + e.Hint
|
|
}
|
|
|
|
return message
|
|
}
|
|
|
|
type UnknownCommandError struct {
|
|
Command string
|
|
}
|
|
|
|
func (e UnknownCommandError) Error() string {
|
|
return "unknown command '" + e.Command + "'"
|
|
}
|