diff --git a/cmd/enbas/main.go b/cmd/enbas/main.go index 187488d..b3ea309 100644 --- a/cmd/enbas/main.go +++ b/cmd/enbas/main.go @@ -112,14 +112,10 @@ func run() error { executor.CommandDelete: executor.NewDeleteExecutor( enbasPrinter, enbasConfig, - executor.CommandDelete, - executor.CommandSummaryLookup(executor.CommandDelete), ), executor.CommandEdit: executor.NewEditExecutor( enbasPrinter, enbasConfig, - executor.CommandEdit, - executor.CommandSummaryLookup(executor.CommandEdit), ), executor.CommandFollow: executor.NewFollowExecutor( enbasPrinter, diff --git a/internal/executor/delete.go b/internal/executor/delete.go index d88d381..0b27fc5 100644 --- a/internal/executor/delete.go +++ b/internal/executor/delete.go @@ -1,39 +1,11 @@ package executor import ( - "flag" "fmt" "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 DeleteExecutor struct { - *flag.FlagSet - - printer *printer.Printer - config *config.Config - resourceType string - listID string -} - -func NewDeleteExecutor(printer *printer.Printer, config *config.Config, name, summary string) *DeleteExecutor { - deleteExe := DeleteExecutor{ - FlagSet: flag.NewFlagSet(name, flag.ExitOnError), - - printer: printer, - config: config, - } - - deleteExe.StringVar(&deleteExe.resourceType, flagType, "", "Specify the type of resource to delete") - deleteExe.StringVar(&deleteExe.listID, flagListID, "", "Specify the ID of the list to delete") - - deleteExe.Usage = commandUsageFunc(name, summary, deleteExe.FlagSet) - - return &deleteExe -} - func (d *DeleteExecutor) Execute() error { if d.resourceType == "" { return FlagNotSetError{flagText: flagType} diff --git a/internal/executor/edit.go b/internal/executor/edit.go index a5f271b..50c7247 100644 --- a/internal/executor/edit.go +++ b/internal/executor/edit.go @@ -1,44 +1,12 @@ package executor import ( - "flag" "fmt" "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" ) -type EditExecutor struct { - *flag.FlagSet - - printer *printer.Printer - config *config.Config - resourceType string - listID string - listTitle string - listRepliesPolicy string -} - -func NewEditExecutor(printer *printer.Printer, config *config.Config, name, summary string) *EditExecutor { - editExe := EditExecutor{ - FlagSet: flag.NewFlagSet(name, flag.ExitOnError), - - printer: printer, - config: config, - } - - editExe.StringVar(&editExe.resourceType, flagType, "", "Specify the type of resource to update") - editExe.StringVar(&editExe.listID, flagListID, "", "Specify the ID of the list to update") - editExe.StringVar(&editExe.listTitle, flagListTitle, "", "Specify the title of the list") - editExe.StringVar(&editExe.listRepliesPolicy, flagListRepliesPolicy, "", "Specify the policy of the replies for this list (valid values are followed, list and none)") - - editExe.Usage = commandUsageFunc(name, summary, editExe.FlagSet) - - return &editExe -} - func (e *EditExecutor) Execute() error { if e.resourceType == "" { return FlagNotSetError{flagText: flagType} diff --git a/internal/executor/executors.go b/internal/executor/executors.go index b4f6b72..9e111fa 100644 --- a/internal/executor/executors.go +++ b/internal/executor/executors.go @@ -64,6 +64,62 @@ func NewBlockExecutor( return &exe } +// DeleteExecutor is the executor for the delete command. +type DeleteExecutor struct { + *flag.FlagSet + printer *printer.Printer + config *config.Config + listID string + resourceType string +} + +func NewDeleteExecutor( + printer *printer.Printer, + config *config.Config, +) *DeleteExecutor { + exe := DeleteExecutor{ + FlagSet: flag.NewFlagSet("delete", flag.ExitOnError), + printer: printer, + config: config, + } + + exe.Usage = commandUsageFunc("delete", "Delete 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)") + return &exe +} + +// EditExecutor is the executor for the edit command. +type EditExecutor struct { + *flag.FlagSet + printer *printer.Printer + config *config.Config + listID string + listTitle string + listRepliesPolicy string + resourceType string +} + +func NewEditExecutor( + printer *printer.Printer, + config *config.Config, +) *EditExecutor { + exe := EditExecutor{ + FlagSet: flag.NewFlagSet("edit", flag.ExitOnError), + printer: printer, + config: config, + } + + exe.Usage = commandUsageFunc("edit", "Edit a specific resource", exe.FlagSet) + + exe.StringVar(&exe.listID, "list-id", "", "The ID of the list in question") + exe.StringVar(&exe.listTitle, "list-title", "", "The title of the list") + exe.StringVar(&exe.listRepliesPolicy, "list-replies-policy", "", "The replies policy of the list") + exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)") + return &exe +} + // FollowExecutor is the executor for the follow command. type FollowExecutor struct { *flag.FlagSet diff --git a/internal/executor/flags.go b/internal/executor/flags.go index 3c53da3..556470e 100644 --- a/internal/executor/flags.go +++ b/internal/executor/flags.go @@ -34,7 +34,6 @@ const ( flagMyAccount = "my-account" flagMuteDuration = "mute-duration" flagMuteNotifications = "mute-notifications" - flagNotify = "notify" flagOnlyMedia = "only-media" flagOnlyPinned = "only-pinned" flagOnlyPublic = "only-public" @@ -46,7 +45,6 @@ const ( flagSensitive = "sensitive" flagSkipRelationship = "skip-relationship" flagShowPreferences = "show-preferences" - flagShowReposts = "show-reposts" flagShowStatuses = "show-statuses" flagSpoilerText = "spoiler-text" flagStatusID = "status-id" diff --git a/schema/enbas_cli_schema.json b/schema/enbas_cli_schema.json index 6a52f30..5cd41fd 100644 --- a/schema/enbas_cli_schema.json +++ b/schema/enbas_cli_schema.json @@ -12,6 +12,18 @@ "type": "string", "description": "The instance that you want to log into" }, + "list-id": { + "type": "string", + "description": "The ID of the list in question" + }, + "list-title": { + "type": "string", + "description": "The title of the list" + }, + "list-replies-policy": { + "type": "string", + "description": "The replies policy of the list" + }, "notify": { "type": "bool", "description": "Get notifications from statuses from the account you want to follow" @@ -51,6 +63,28 @@ "useConfig": true, "usePrinter": true }, + "delete": { + "additionalFields": [], + "flags": [ + { "flag": "list-id", "fieldName": "listID", "default": ""}, + { "flag": "type", "fieldName": "resourceType", "default": "" } + ], + "summary": "Delete a specific resource", + "useConfig": true, + "usePrinter": true + }, + "edit": { + "additionalFields": [], + "flags": [ + { "flag": "list-id", "fieldName": "listID", "default": ""}, + { "flag": "list-title", "default": "" }, + { "flag": "list-replies-policy", "default": "" }, + { "flag": "type", "fieldName": "resourceType", "default": "" } + ], + "summary": "Edit a specific resource", + "useConfig": true, + "usePrinter": true + }, "follow": { "additionalFields": [], "flags": [