Compare commits

...

2 commits

10 changed files with 465 additions and 263 deletions

View file

@ -36,10 +36,11 @@ func main() {
func generateExecutors(schema enbasCLISchema, output string) error {
funcMap := template.FuncMap{
"capitalise": capitalise,
"flagFieldName": flagFieldName,
"getFlagType": schema.Flags.getType,
"getFlagDescription": schema.Flags.getDescription,
"capitalise": capitalise,
"flagFieldName": flagFieldName,
"getFlagType": schema.Flags.getType,
"getFlagDescription": schema.Flags.getDescription,
"customFlagValueType": customFlagValueType,
}
tmpl := template.Must(template.New("executor-template").Funcs(funcMap).Parse(executorsFileTemplate))
@ -107,3 +108,16 @@ func convertFlagToMixedCaps(value string) string {
return builder.String()
}
func customFlagValueType(flagType string) bool {
customFlagValueTypes := map[string]struct{}{
"MultiStringFlagValue": {},
"MultiIntFlagValue": {},
"TimeDurationFlagValue": {},
"BoolPtrFlagValue": {},
}
_, exists := customFlagValueTypes[flagType]
return exists
}

View file

@ -51,6 +51,13 @@ func {{ $new_executor_function_name }}(
{{- if $command.UseConfig }}
config: config,
{{- end }}
{{- range $flag := $command.Flags -}}
{{- $flag_type := getFlagType $flag.Flag -}}
{{- if customFlagValueType $flag_type -}}
{{ print "" }}
{{ flagFieldName $flag }}: New{{ $flag_type }}(),
{{- end -}}
{{- end -}}
{{- range $field := $command.AdditionalFields -}}
{{ print "" }}
{{ $field.Name }}: {{ $field.Name }},
@ -61,12 +68,16 @@ func {{ $new_executor_function_name }}(
exe.Usage = commandUsageFunc({{ printf "%q" $name }}, {{ printf "%q" $command.Summary }}, exe.FlagSet)
{{ print "" }}
{{- range $flag := $command.Flags -}}
{{- if eq (getFlagType $flag.Flag) "string" -}}
{{- $flag_type := getFlagType $flag.Flag -}}
{{- if eq $flag_type "string" -}}
{{ print "" }}
exe.StringVar(&exe.{{ flagFieldName $flag }}, {{ printf "%q" $flag.Flag }}, {{ printf "%q" $flag.Default }}, {{ getFlagDescription $flag.Flag | printf "%q" }})
{{- else if eq (getFlagType $flag.Flag) "bool" -}}
{{- else if eq $flag_type "bool" -}}
{{ print "" }}
exe.BoolVar(&exe.{{ flagFieldName $flag }}, {{ printf "%q" $flag.Flag }}, {{ $flag.Default }}, {{ getFlagDescription $flag.Flag | printf "%q" }})
{{- else if customFlagValueType $flag_type -}}
{{ print "" }}
exe.Var(&exe.{{ flagFieldName $flag }}, {{ printf "%q" $flag.Flag }}, {{ getFlagDescription $flag.Flag | printf "%q" }})
{{- end -}}
{{- end -}}
{{ print "" }}

View file

@ -106,8 +106,6 @@ func run() error {
executor.CommandCreate: executor.NewCreateExecutor(
enbasPrinter,
enbasConfig,
executor.CommandCreate,
executor.CommandSummaryLookup(executor.CommandCreate),
),
executor.CommandDelete: executor.NewDeleteExecutor(
enbasPrinter,
@ -129,11 +127,9 @@ func run() error {
enbasPrinter,
enbasConfig,
),
executor.CommandMute: executor.NewMuteOrUnmuteExecutor(
executor.CommandMute: executor.NewMuteExecutor(
enbasPrinter,
enbasConfig,
executor.CommandMute,
executor.CommandSummaryLookup(executor.CommandMute),
),
executor.CommandReject: executor.NewRejectExecutor(
enbasPrinter,
@ -153,11 +149,9 @@ func run() error {
enbasPrinter,
enbasConfig,
),
executor.CommandUnmute: executor.NewMuteOrUnmuteExecutor(
executor.CommandUnmute: executor.NewUnmuteExecutor(
enbasPrinter,
enbasConfig,
executor.CommandUnmute,
executor.CommandSummaryLookup(executor.CommandUnmute),
),
executor.CommandUnblock: executor.NewUnblockExecutor(
enbasPrinter,

View file

@ -1,94 +1,13 @@
package executor
import (
"flag"
"fmt"
"strconv"
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
"codeflow.dananglin.me.uk/apollo/enbas/internal/config"
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
"codeflow.dananglin.me.uk/apollo/enbas/internal/printer"
"codeflow.dananglin.me.uk/apollo/enbas/internal/utilities"
)
type CreateExecutor struct {
*flag.FlagSet
printer *printer.Printer
config *config.Config
addPoll bool
boostable bool
federated bool
likeable bool
pollAllowsMultipleChoices bool
pollHidesVoteCounts bool
replyable bool
sensitive *bool
content string
contentType string
fromFile string
inReplyTo string
language string
resourceType string
listTitle string
listRepliesPolicy string
spoilerText string
visibility string
pollExpiresIn TimeDurationFlagValue
pollOptions MultiStringFlagValue
}
func NewCreateExecutor(printer *printer.Printer, config *config.Config, name, summary string) *CreateExecutor {
createExe := CreateExecutor{
FlagSet: flag.NewFlagSet(name, flag.ExitOnError),
printer: printer,
config: config,
}
createExe.StringVar(&createExe.resourceType, flagType, "", "Specify the type of resource to create")
// Flags for statuses
createExe.BoolVar(&createExe.boostable, flagEnableReposts, true, "Specify if the status can be reposted/boosted by others")
createExe.StringVar(&createExe.content, flagContent, "", "The content of the status to create")
createExe.StringVar(&createExe.contentType, flagContentType, "plain", "The type that the contents should be parsed from (valid values are plain and markdown)")
createExe.BoolVar(&createExe.federated, flagEnableFederation, true, "Specify if the status can be federated beyond the local timelines")
createExe.StringVar(&createExe.fromFile, flagFromFile, "", "The file path where to read the contents from")
createExe.StringVar(&createExe.inReplyTo, flagInReplyTo, "", "The ID of the status that you want to reply to")
createExe.StringVar(&createExe.language, flagLanguage, "", "The ISO 639 language code for this status")
createExe.BoolVar(&createExe.likeable, flagEnableLikes, true, "Specify if the status can be liked/favourited")
createExe.BoolVar(&createExe.replyable, flagEnableReplies, true, "Specify if the status can be replied to")
createExe.StringVar(&createExe.spoilerText, flagSpoilerText, "", "The text to display as the status' warning or subject")
createExe.StringVar(&createExe.visibility, flagVisibility, "", "The visibility of the posted status")
createExe.BoolFunc(flagSensitive, "Specify if the status should be marked as sensitive", func(value string) error {
boolVal, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("unable to parse %q as a boolean value: %w", value, err)
}
createExe.sensitive = new(bool)
*createExe.sensitive = boolVal
return nil
})
// Flags specifically for polls
createExe.BoolVar(&createExe.addPoll, flagAddPoll, false, "Add a poll to the status")
createExe.BoolVar(&createExe.pollAllowsMultipleChoices, flagPollAllowsMultipleChoices, false, "The poll allows viewers to make multiple choices in the poll")
createExe.BoolVar(&createExe.pollHidesVoteCounts, flagPollHidesVoteCounts, false, "The poll will hide the vote count until it is closed")
createExe.Var(&createExe.pollOptions, flagPollOption, "A poll option. Use this multiple times to set multiple options")
createExe.Var(&createExe.pollExpiresIn, flagPollExpiresIn, "The duration in which the poll is open for")
// Flags for lists
createExe.StringVar(&createExe.listTitle, flagListTitle, "", "Specify the title of the list")
createExe.StringVar(&createExe.listRepliesPolicy, flagListRepliesPolicy, "list", "Specify the policy of the replies for this list (valid values are followed, list and none)")
createExe.Usage = commandUsageFunc(name, summary, createExe.FlagSet)
return &createExe
}
func (c *CreateExecutor) Execute() error {
if c.resourceType == "" {
return FlagNotSetError{flagText: flagType}
@ -179,8 +98,8 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
visibility = preferences.PostingDefaultVisibility
}
if c.sensitive != nil {
sensitive = *c.sensitive
if c.sensitive.Value != nil {
sensitive = *c.sensitive.Value
} else {
sensitive = preferences.PostingDefaultSensitive
}

View file

@ -64,6 +64,71 @@ func NewBlockExecutor(
return &exe
}
// CreateExecutor is the executor for the create command.
type CreateExecutor struct {
*flag.FlagSet
printer *printer.Printer
config *config.Config
addPoll bool
content string
contentType string
federated bool
likeable bool
replyable bool
boostable bool
fromFile string
inReplyTo string
language string
listRepliesPolicy string
listTitle string
pollAllowsMultipleChoices bool
pollExpiresIn TimeDurationFlagValue
pollHidesVoteCounts bool
pollOptions MultiStringFlagValue
sensitive BoolPtrFlagValue
spoilerText string
resourceType string
visibility string
}
func NewCreateExecutor(
printer *printer.Printer,
config *config.Config,
) *CreateExecutor {
exe := CreateExecutor{
FlagSet: flag.NewFlagSet("create", flag.ExitOnError),
printer: printer,
config: config,
pollExpiresIn: NewTimeDurationFlagValue(),
pollOptions: NewMultiStringFlagValue(),
sensitive: NewBoolPtrFlagValue(),
}
exe.Usage = commandUsageFunc("create", "Creates a specific resource", exe.FlagSet)
exe.BoolVar(&exe.addPoll, "add-poll", false, "Set to true to add a poll when creating a status")
exe.StringVar(&exe.content, "content", "", "The content of the created resource")
exe.StringVar(&exe.contentType, "content-type", "plain", "The type that the contents should be parsed from (valid values are plain and markdown)")
exe.BoolVar(&exe.federated, "enable-federation", true, "Set to true to federate the status beyond the local timelines")
exe.BoolVar(&exe.likeable, "enable-likes", true, "Set to true to allow the status to be liked (favourited)")
exe.BoolVar(&exe.replyable, "enable-replies", true, "Set to true to allow viewers to reply to the status")
exe.BoolVar(&exe.boostable, "enable-reposts", true, "Set to true to allow the status to be reposted (boosted) by others")
exe.StringVar(&exe.fromFile, "from-file", "", "The file path where to read the contents from")
exe.StringVar(&exe.inReplyTo, "in-reply-to", "", "The ID of the status that you want to reply to")
exe.StringVar(&exe.language, "language", "", "The ISO 639 language code for this status")
exe.StringVar(&exe.listRepliesPolicy, "list-replies-policy", "list", "The replies policy of the list")
exe.StringVar(&exe.listTitle, "list-title", "", "The title of the list")
exe.BoolVar(&exe.pollAllowsMultipleChoices, "poll-allows-multiple-choices", false, "Set to true to allow viewers to make multiple choices in the poll")
exe.Var(&exe.pollExpiresIn, "poll-expires-in", "The duration in which the poll is open for")
exe.BoolVar(&exe.pollHidesVoteCounts, "poll-hides-vote-counts", false, "Set to true to hide the vote count until the poll is closed")
exe.Var(&exe.pollOptions, "poll-option", "A poll option. Use this multiple times to set multiple options")
exe.Var(&exe.sensitive, "sensitive", "Set to true if the status should be marked as sensitive")
exe.StringVar(&exe.spoilerText, "spoiler-text", "", "The text to display as the status' warning or subject")
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
exe.StringVar(&exe.visibility, "visibility", "", "The visibility of the posted status")
return &exe
}
// DeleteExecutor is the executor for the delete command.
type DeleteExecutor struct {
*flag.FlagSet
@ -83,7 +148,7 @@ func NewDeleteExecutor(
config: config,
}
exe.Usage = commandUsageFunc("delete", "Delete a specific resource", exe.FlagSet)
exe.Usage = commandUsageFunc("delete", "Deletes a specific resource", exe.FlagSet)
exe.StringVar(&exe.listID, "list-id", "", "The ID of the list in question")
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
@ -196,6 +261,37 @@ func NewLoginExecutor(
return &exe
}
// MuteExecutor is the executor for the mute command.
type MuteExecutor struct {
*flag.FlagSet
printer *printer.Printer
config *config.Config
accountName string
muteDuration TimeDurationFlagValue
muteNotifications bool
resourceType string
}
func NewMuteExecutor(
printer *printer.Printer,
config *config.Config,
) *MuteExecutor {
exe := MuteExecutor{
FlagSet: flag.NewFlagSet("mute", flag.ExitOnError),
printer: printer,
config: config,
muteDuration: NewTimeDurationFlagValue(),
}
exe.Usage = commandUsageFunc("mute", "Mutes a specific resource (e.g. an account)", exe.FlagSet)
exe.StringVar(&exe.accountName, "account-name", "", "The name of the account")
exe.Var(&exe.muteDuration, "mute-duration", "Specify how long the mute should last for. To mute indefinitely, set this to 0s")
exe.BoolVar(&exe.muteNotifications, "mute-notifications", false, "Set to true to mute notifications as well as posts")
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
return &exe
}
// RejectExecutor is the executor for the reject command.
type RejectExecutor struct {
*flag.FlagSet
@ -300,6 +396,32 @@ func NewUnfollowExecutor(
return &exe
}
// UnmuteExecutor is the executor for the unmute command.
type UnmuteExecutor struct {
*flag.FlagSet
printer *printer.Printer
config *config.Config
accountName string
resourceType string
}
func NewUnmuteExecutor(
printer *printer.Printer,
config *config.Config,
) *UnmuteExecutor {
exe := UnmuteExecutor{
FlagSet: flag.NewFlagSet("unmute", flag.ExitOnError),
printer: printer,
config: config,
}
exe.Usage = commandUsageFunc("unmute", "Umutes a specific resource (e.g. an account)", exe.FlagSet)
exe.StringVar(&exe.accountName, "account-name", "", "The name of the account")
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
return &exe
}
// VersionExecutor is the executor for the version command.
type VersionExecutor struct {
*flag.FlagSet

View file

@ -8,58 +8,47 @@ import (
)
const (
flagAddPoll = "add-poll"
flagAccountName = "account-name"
flagAllImages = "all-images"
flagAllVideos = "all-videos"
flagAttachmentID = "attachment-id"
flagBrowser = "browser"
flagContentType = "content-type"
flagContent = "content"
flagEnableFederation = "enable-federation"
flagEnableLikes = "enable-likes"
flagEnableReplies = "enable-replies"
flagEnableReposts = "enable-reposts"
flagExcludeBoosts = "exclude-boosts"
flagExcludeReplies = "exclude-replies"
flagFrom = "from"
flagFromFile = "from-file"
flagInReplyTo = "in-reply-to"
flagInstance = "instance"
flagLanguage = "language"
flagLimit = "limit"
flagListID = "list-id"
flagListTitle = "list-title"
flagListRepliesPolicy = "list-replies-policy"
flagMyAccount = "my-account"
flagMuteDuration = "mute-duration"
flagMuteNotifications = "mute-notifications"
flagOnlyMedia = "only-media"
flagOnlyPinned = "only-pinned"
flagOnlyPublic = "only-public"
flagPollAllowsMultipleChoices = "poll-allows-multiple-choices"
flagPollExpiresIn = "poll-expires-in"
flagPollHidesVoteCounts = "poll-hides-vote-counts"
flagPollID = "poll-id"
flagPollOption = "poll-option"
flagSensitive = "sensitive"
flagSkipRelationship = "skip-relationship"
flagShowPreferences = "show-preferences"
flagShowStatuses = "show-statuses"
flagSpoilerText = "spoiler-text"
flagStatusID = "status-id"
flagTag = "tag"
flagTimelineCategory = "timeline-category"
flagTo = "to"
flagType = "type"
flagVisibility = "visibility"
flagVote = "vote"
flagAccountName = "account-name"
flagAllImages = "all-images"
flagAllVideos = "all-videos"
flagAttachmentID = "attachment-id"
flagBrowser = "browser"
flagContent = "content"
flagExcludeBoosts = "exclude-boosts"
flagExcludeReplies = "exclude-replies"
flagFrom = "from"
flagFromFile = "from-file"
flagInstance = "instance"
flagLimit = "limit"
flagListID = "list-id"
flagListTitle = "list-title"
flagMyAccount = "my-account"
flagOnlyMedia = "only-media"
flagOnlyPinned = "only-pinned"
flagOnlyPublic = "only-public"
flagPollID = "poll-id"
flagPollOption = "poll-option"
flagSkipRelationship = "skip-relationship"
flagShowPreferences = "show-preferences"
flagShowStatuses = "show-statuses"
flagStatusID = "status-id"
flagTag = "tag"
flagTimelineCategory = "timeline-category"
flagTo = "to"
flagType = "type"
flagVote = "vote"
)
type MultiStringFlagValue []string
func (v *MultiStringFlagValue) String() string {
return strings.Join(*v, ", ")
func NewMultiStringFlagValue() MultiStringFlagValue {
arr := make([]string, 0, 3)
return MultiStringFlagValue(arr)
}
func (v MultiStringFlagValue) String() string {
return strings.Join(v, ", ")
}
func (v *MultiStringFlagValue) Set(value string) error {
@ -72,11 +61,17 @@ func (v *MultiStringFlagValue) Set(value string) error {
type MultiIntFlagValue []int
func (v *MultiIntFlagValue) String() string {
func NewMultiIntFlagValue() MultiIntFlagValue {
arr := make([]int, 0, 3)
return MultiIntFlagValue(arr)
}
func (v MultiIntFlagValue) String() string {
value := "Choices: "
for ind, vote := range *v {
if ind == len(*v)-1 {
for ind, vote := range v {
if ind == len(v)-1 {
value += strconv.Itoa(vote)
} else {
value += strconv.Itoa(vote) + ", "
@ -101,8 +96,14 @@ type TimeDurationFlagValue struct {
Duration time.Duration
}
func NewTimeDurationFlagValue() TimeDurationFlagValue {
return TimeDurationFlagValue{
Duration: 0 * time.Second,
}
}
func (v TimeDurationFlagValue) String() string {
return ""
return "Time duration: " + v.Duration.String()
}
func (v *TimeDurationFlagValue) Set(text string) error {
@ -115,3 +116,33 @@ func (v *TimeDurationFlagValue) Set(text string) error {
return nil
}
type BoolPtrFlagValue struct {
Value *bool
}
func NewBoolPtrFlagValue() BoolPtrFlagValue {
return BoolPtrFlagValue{
Value: nil,
}
}
func (b BoolPtrFlagValue) String() string {
if b.Value == nil {
return "NOT SET"
}
return strconv.FormatBool(*b.Value)
}
func (b *BoolPtrFlagValue) Set(value string) error {
boolVar, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("unable to parse %q as a boolean value: %w", value, err)
}
b.Value = new(bool)
*b.Value = boolVar
return nil
}

49
internal/executor/mute.go Normal file
View file

@ -0,0 +1,49 @@
package executor
import (
"fmt"
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
)
func (m *MuteExecutor) Execute() error {
funcMap := map[string]func(*client.Client) error{
resourceAccount: m.muteAccount,
}
doFunc, ok := funcMap[m.resourceType]
if !ok {
return UnsupportedTypeError{resourceType: m.resourceType}
}
gtsClient, err := client.NewClientFromFile(m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("unable to create the GoToSocial client: %w", err)
}
return doFunc(gtsClient)
}
func (m *MuteExecutor) muteAccount(gtsClient *client.Client) error {
if m.accountName == "" {
return FlagNotSetError{flagText: flagAccountName}
}
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}
form := client.MuteAccountForm{
Notifications: m.muteNotifications,
Duration: int(m.muteDuration.Duration.Seconds()),
}
if err := gtsClient.MuteAccount(accountID, form); err != nil {
return fmt.Errorf("unable to mute the account: %w", err)
}
m.printer.PrintSuccess("Successfully muted the account.")
return nil
}

View file

@ -1,108 +0,0 @@
package executor
import (
"flag"
"fmt"
"time"
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
"codeflow.dananglin.me.uk/apollo/enbas/internal/config"
"codeflow.dananglin.me.uk/apollo/enbas/internal/printer"
)
type MuteOrUnmuteExecutor struct {
*flag.FlagSet
printer *printer.Printer
config *config.Config
accountName string
command string
resourceType string
muteDuration TimeDurationFlagValue
muteNotifications bool
}
func NewMuteOrUnmuteExecutor(printer *printer.Printer, config *config.Config, name, summary string) *MuteOrUnmuteExecutor {
muteDuration := TimeDurationFlagValue{time.Duration(0 * time.Second)}
exe := MuteOrUnmuteExecutor{
FlagSet: flag.NewFlagSet(name, flag.ExitOnError),
printer: printer,
config: config,
command: name,
muteDuration: muteDuration,
}
exe.StringVar(&exe.accountName, flagAccountName, "", "Specify the account name in full (username@domain)")
exe.StringVar(&exe.resourceType, flagType, "", "Specify the type of resource to mute or unmute")
exe.BoolVar(&exe.muteNotifications, flagMuteNotifications, false, "Mute notifications as well as posts")
exe.Var(&exe.muteDuration, flagMuteDuration, "Specify how long the mute should last for. To mute indefinitely, set this to 0s")
exe.Usage = commandUsageFunc(name, summary, exe.FlagSet)
return &exe
}
func (m *MuteOrUnmuteExecutor) Execute() error {
funcMap := map[string]func(*client.Client) error{
resourceAccount: m.muteOrUnmuteAccount,
}
doFunc, ok := funcMap[m.resourceType]
if !ok {
return UnsupportedTypeError{resourceType: m.resourceType}
}
gtsClient, err := client.NewClientFromFile(m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("unable to create the GoToSocial client: %w", err)
}
return doFunc(gtsClient)
}
func (m *MuteOrUnmuteExecutor) muteOrUnmuteAccount(gtsClient *client.Client) error {
if m.accountName == "" {
return FlagNotSetError{flagText: flagAccountName}
}
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}
switch m.command {
case CommandMute:
return m.muteAccount(gtsClient, accountID)
case CommandUnmute:
return m.unmuteAccount(gtsClient, accountID)
default:
return nil
}
}
func (m *MuteOrUnmuteExecutor) muteAccount(gtsClient *client.Client, accountID string) error {
form := client.MuteAccountForm{
Notifications: m.muteNotifications,
Duration: int(m.muteDuration.Duration.Seconds()),
}
if err := gtsClient.MuteAccount(accountID, form); err != nil {
return fmt.Errorf("unable to mute the account: %w", err)
}
m.printer.PrintSuccess("Successfully muted the account.")
return nil
}
func (m *MuteOrUnmuteExecutor) unmuteAccount(gtsClient *client.Client, accountID string) error {
if err := gtsClient.UnmuteAccount(accountID); err != nil {
return fmt.Errorf("unable to unmute the account: %w", err)
}
m.printer.PrintSuccess("Successfully unmuted the account.")
return nil
}

View file

@ -0,0 +1,44 @@
package executor
import (
"fmt"
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
)
func (m *UnmuteExecutor) Execute() error {
funcMap := map[string]func(*client.Client) error{
resourceAccount: m.unmuteAccount,
}
doFunc, ok := funcMap[m.resourceType]
if !ok {
return UnsupportedTypeError{resourceType: m.resourceType}
}
gtsClient, err := client.NewClientFromFile(m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("unable to create the GoToSocial client: %w", err)
}
return doFunc(gtsClient)
}
func (m *UnmuteExecutor) unmuteAccount(gtsClient *client.Client) error {
if m.accountName == "" {
return FlagNotSetError{flagText: flagAccountName}
}
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}
if err := gtsClient.UnmuteAccount(accountID); err != nil {
return fmt.Errorf("unable to unmute the account: %w", err)
}
m.printer.PrintSuccess("Successfully unmuted the account.")
return nil
}

View file

@ -4,34 +4,106 @@
"type": "string",
"description": "The name of the account"
},
"add-poll": {
"type": "bool",
"description": "Set to true to add a poll when creating a status"
},
"content": {
"type": "string",
"description": "The content of the created resource"
},
"content-type": {
"type": "string",
"description": "The type that the contents should be parsed from (valid values are plain and markdown)"
},
"enable-federation": {
"type": "bool",
"description": "Set to true to federate the status beyond the local timelines"
},
"enable-likes": {
"type": "bool",
"description": "Set to true to allow the status to be liked (favourited)"
},
"enable-replies": {
"type": "bool",
"description": "Set to true to allow viewers to reply to the status"
},
"enable-reposts": {
"type": "bool",
"description": "Set to true to allow the status to be reposted (boosted) by others"
},
"from-file": {
"type": "string",
"description": "The file path where to read the contents from"
},
"full": {
"type": "bool",
"description": "Set to true to print the build information in full"
},
"in-reply-to": {
"type": "string",
"description": "The ID of the status that you want to reply to"
},
"instance": {
"type": "string",
"description": "The instance that you want to log into"
},
"language": {
"type": "string",
"description": "The ISO 639 language code for this status"
},
"list-id": {
"type": "string",
"description": "The ID of the list in question"
},
"list-title": {
"type": "string",
"description": "The title of the list"
"type": "string",
"description": "The title of the list"
},
"list-replies-policy": {
"type": "string",
"description": "The replies policy of the list"
"type": "string",
"description": "The replies policy of the list"
},
"mute-duration": {
"type": "TimeDurationFlagValue",
"description": "Specify how long the mute should last for. To mute indefinitely, set this to 0s"
},
"mute-notifications": {
"type": "bool",
"description": "Set to true to mute notifications as well as posts"
},
"notify": {
"type": "bool",
"description": "Get notifications from statuses from the account you want to follow"
},
"poll-allows-multiple-choices": {
"type": "bool",
"description": "Set to true to allow viewers to make multiple choices in the poll"
},
"poll-expires-in": {
"type": "TimeDurationFlagValue",
"description": "The duration in which the poll is open for"
},
"poll-hides-vote-counts": {
"type": "bool",
"description": "Set to true to hide the vote count until the poll is closed"
},
"poll-option": {
"type": "MultiStringFlagValue",
"description": "A poll option. Use this multiple times to set multiple options"
},
"sensitive": {
"type": "BoolPtrFlagValue",
"description": "Set to true if the status should be marked as sensitive"
},
"show-reposts": {
"type": "bool",
"description": "Show reposts from the account you want to follow"
},
"spoiler-text": {
"type": "string",
"description": "The text to display as the status' warning or subject"
},
"type": {
"type": "string",
"description": "The type of resource you want to action on (e.g. account, status)"
@ -39,6 +111,10 @@
"to": {
"type": "string",
"description": "TBC"
},
"visibility": {
"type": "string",
"description": "The visibility of the posted status"
}
},
@ -63,13 +139,41 @@
"useConfig": true,
"usePrinter": true
},
"create": {
"additionalFields": [],
"flags": [
{ "flag": "add-poll", "default": "false" },
{ "flag": "content", "default": "" },
{ "flag": "content-type", "default": "plain" },
{ "flag": "enable-federation", "fieldName": "federated", "default": "true" },
{ "flag": "enable-likes", "fieldName": "likeable", "default": "true" },
{ "flag": "enable-replies", "fieldName": "replyable", "default": "true" },
{ "flag": "enable-reposts", "fieldName": "boostable", "default": "true" },
{ "flag": "from-file", "default": "" },
{ "flag": "in-reply-to", "default": "" },
{ "flag": "language", "default": "" },
{ "flag": "list-replies-policy", "default": "list" },
{ "flag": "list-title", "default": "" },
{ "flag": "poll-allows-multiple-choices", "default": "false" },
{ "flag": "poll-expires-in" },
{ "flag": "poll-hides-vote-counts", "default": "false" },
{ "flag": "poll-option", "fieldName": "pollOptions" },
{ "flag": "sensitive" },
{ "flag": "spoiler-text", "default": "" },
{ "flag": "type", "fieldName": "resourceType", "default": "" },
{ "flag": "visibility", "default": "" }
],
"summary": "Creates a specific resource",
"useConfig": true,
"usePrinter": true
},
"delete": {
"additionalFields": [],
"flags": [
{ "flag": "list-id", "fieldName": "listID", "default": ""},
{ "flag": "type", "fieldName": "resourceType", "default": "" }
],
"summary": "Delete a specific resource",
"summary": "Deletes a specific resource",
"useConfig": true,
"usePrinter": true
},
@ -115,6 +219,18 @@
"useConfig": true,
"usePrinter": true
},
"mute": {
"additionalFields": [],
"flags": [
{ "flag": "account-name", "default": "" },
{ "flag": "mute-duration" },
{ "flag": "mute-notifications", "default": "false" },
{ "flag": "type", "fieldName": "resourceType", "default": "" }
],
"summary": "Mutes a specific resource (e.g. an account)",
"useConfig": true,
"usePrinter": true
},
"reject": {
"additionalFields": [],
"flags": [
@ -155,6 +271,16 @@
"useConfig": true,
"usePrinter": true
},
"unmute": {
"additionalFields": [],
"flags": [
{ "flag": "account-name", "default": "" },
{ "flag": "type", "fieldName": "resourceType", "default": "" }
],
"summary": "Umutes a specific resource (e.g. an account)",
"useConfig": true,
"usePrinter": true
},
"version": {
"additionalFields": [
{ "name": "binaryVersion", "type": "string"},