enbas/internal/executor/errors.go
Dan Anglin 42251f6df8
feat: add configuration support to enbas
SUMMARY

This commit adds configuration support to enbas. The configuration is
stored as a JSON file in the user specified configuration directory.

When using enbas for the first time, the user will first need to
execute the new init command in order to generate the configuration.
Once this has been generated the user can edit the settings to
personalise their experience, login to their account and use enbas as
normal.

For now the configurable settings included in the configuration
are as follows:

- The path to the credentials file (by default this is set to a file in
  the same directory as the configuration file).
- The path to the cache directory.
- The character limit used for line wrapping.
- The programs used for integrations such as paging, media viewing,
  opening URLs, etc.

CHANGES

- added the new config type.
- added the new init executor for generating a new configuration file.
- removed the following top level flags in favour of the new
  configration support.
    - cache-dir
    - pager
    - image-viewer
    - video-player
    - max-terminal-width
- added a new error type for use when an unknown media attachment ID
  is specified.
- updated the usage function for the executors to support a case
  where a flagsets has no flags.
- update .golangci.yaml to disable some linters
2024-06-25 12:39:39 +01:00

112 lines
2.3 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 + "'"
}
type PollClosedError struct{}
func (e PollClosedError) Error() string {
return "this poll is closed"
}
type MultipleChoiceError struct{}
func (e MultipleChoiceError) Error() string {
return "this poll does not allow multiple choices"
}
type NoPollOptionError struct{}
func (e NoPollOptionError) Error() string {
return "no options were provided for this poll, please use the --" +
flagPollOption +
" flag to add options to the poll"
}
type NotFollowingError struct {
Account string
}
func (e NotFollowingError) Error() string {
return "you are not following " + e.Account
}
type UnknownMediaAttachmentError struct {
AttachmentID string
}
func (e UnknownMediaAttachmentError) Error() string {
return "unknown media attachment '" + e.AttachmentID + "'"
}