checkpoint: add edit and delete to schema
This commit is contained in:
parent
93bc7a93f8
commit
9d509af0df
6 changed files with 90 additions and 66 deletions
|
@ -112,14 +112,10 @@ func run() error {
|
||||||
executor.CommandDelete: executor.NewDeleteExecutor(
|
executor.CommandDelete: executor.NewDeleteExecutor(
|
||||||
enbasPrinter,
|
enbasPrinter,
|
||||||
enbasConfig,
|
enbasConfig,
|
||||||
executor.CommandDelete,
|
|
||||||
executor.CommandSummaryLookup(executor.CommandDelete),
|
|
||||||
),
|
),
|
||||||
executor.CommandEdit: executor.NewEditExecutor(
|
executor.CommandEdit: executor.NewEditExecutor(
|
||||||
enbasPrinter,
|
enbasPrinter,
|
||||||
enbasConfig,
|
enbasConfig,
|
||||||
executor.CommandEdit,
|
|
||||||
executor.CommandSummaryLookup(executor.CommandEdit),
|
|
||||||
),
|
),
|
||||||
executor.CommandFollow: executor.NewFollowExecutor(
|
executor.CommandFollow: executor.NewFollowExecutor(
|
||||||
enbasPrinter,
|
enbasPrinter,
|
||||||
|
|
|
@ -1,39 +1,11 @@
|
||||||
package executor
|
package executor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
"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 {
|
func (d *DeleteExecutor) Execute() error {
|
||||||
if d.resourceType == "" {
|
if d.resourceType == "" {
|
||||||
return FlagNotSetError{flagText: flagType}
|
return FlagNotSetError{flagText: flagType}
|
||||||
|
|
|
@ -1,44 +1,12 @@
|
||||||
package executor
|
package executor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
"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/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 {
|
func (e *EditExecutor) Execute() error {
|
||||||
if e.resourceType == "" {
|
if e.resourceType == "" {
|
||||||
return FlagNotSetError{flagText: flagType}
|
return FlagNotSetError{flagText: flagType}
|
||||||
|
|
|
@ -64,6 +64,62 @@ func NewBlockExecutor(
|
||||||
return &exe
|
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.
|
// FollowExecutor is the executor for the follow command.
|
||||||
type FollowExecutor struct {
|
type FollowExecutor struct {
|
||||||
*flag.FlagSet
|
*flag.FlagSet
|
||||||
|
|
|
@ -34,7 +34,6 @@ const (
|
||||||
flagMyAccount = "my-account"
|
flagMyAccount = "my-account"
|
||||||
flagMuteDuration = "mute-duration"
|
flagMuteDuration = "mute-duration"
|
||||||
flagMuteNotifications = "mute-notifications"
|
flagMuteNotifications = "mute-notifications"
|
||||||
flagNotify = "notify"
|
|
||||||
flagOnlyMedia = "only-media"
|
flagOnlyMedia = "only-media"
|
||||||
flagOnlyPinned = "only-pinned"
|
flagOnlyPinned = "only-pinned"
|
||||||
flagOnlyPublic = "only-public"
|
flagOnlyPublic = "only-public"
|
||||||
|
@ -46,7 +45,6 @@ const (
|
||||||
flagSensitive = "sensitive"
|
flagSensitive = "sensitive"
|
||||||
flagSkipRelationship = "skip-relationship"
|
flagSkipRelationship = "skip-relationship"
|
||||||
flagShowPreferences = "show-preferences"
|
flagShowPreferences = "show-preferences"
|
||||||
flagShowReposts = "show-reposts"
|
|
||||||
flagShowStatuses = "show-statuses"
|
flagShowStatuses = "show-statuses"
|
||||||
flagSpoilerText = "spoiler-text"
|
flagSpoilerText = "spoiler-text"
|
||||||
flagStatusID = "status-id"
|
flagStatusID = "status-id"
|
||||||
|
|
|
@ -12,6 +12,18 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The instance that you want to log into"
|
"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": {
|
"notify": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"description": "Get notifications from statuses from the account you want to follow"
|
"description": "Get notifications from statuses from the account you want to follow"
|
||||||
|
@ -51,6 +63,28 @@
|
||||||
"useConfig": true,
|
"useConfig": true,
|
||||||
"usePrinter": 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": {
|
"follow": {
|
||||||
"additionalFields": [],
|
"additionalFields": [],
|
||||||
"flags": [
|
"flags": [
|
||||||
|
|
Loading…
Reference in a new issue