add appropiate prefix to const names

This commit is contained in:
Dan Anglin 2024-05-23 02:30:34 +01:00
parent 3d17c30d0f
commit 3e9290897c
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
11 changed files with 166 additions and 163 deletions

View file

@ -28,11 +28,11 @@ func newAddCommand(tlf topLevelFlags, name, summary string) *addCommand {
topLevelFlags: tlf,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the resource type to add (e.g. account, note)")
command.StringVar(&command.toResourceType, addToFlag, "", "specify the target resource type to add to (e.g. list, account, etc)")
command.StringVar(&command.listID, listIDFlag, "", "the ID of the list to add to")
command.Var(&command.accountNames, accountNameFlag, "the name of the account to add to the resource")
command.StringVar(&command.content, contentFlag, "", "the content of the note")
command.StringVar(&command.resourceType, flagType, "", "specify the resource type to add (e.g. account, note)")
command.StringVar(&command.toResourceType, flagTo, "", "specify the target resource type to add to (e.g. list, account, etc)")
command.StringVar(&command.listID, flagListID, "", "the ID of the list to add to")
command.Var(&command.accountNames, flagAccountName, "the name of the account to add to the resource")
command.StringVar(&command.content, flagContent, "", "the content of the note")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -41,12 +41,12 @@ func newAddCommand(tlf topLevelFlags, name, summary string) *addCommand {
func (c *addCommand) Execute() error {
if c.toResourceType == "" {
return flagNotSetError{flagText: addToFlag}
return flagNotSetError{flagText: flagTo}
}
funcMap := map[string]func(*client.Client) error{
listResource: c.addToList,
accountResource: c.addToAccount,
resourceList: c.addToList,
resourceAccount: c.addToAccount,
}
doFunc, ok := funcMap[c.toResourceType]
@ -64,7 +64,7 @@ func (c *addCommand) Execute() error {
func (c *addCommand) addToList(gtsClient *client.Client) error {
funcMap := map[string]func(*client.Client) error{
accountResource: c.addAccountsToList,
resourceAccount: c.addAccountsToList,
}
doFunc, ok := funcMap[c.resourceType]
@ -80,7 +80,7 @@ func (c *addCommand) addToList(gtsClient *client.Client) error {
func (c *addCommand) addAccountsToList(gtsClient *client.Client) error {
if c.listID == "" {
return flagNotSetError{flagText: listIDFlag}
return flagNotSetError{flagText: flagListID}
}
if len(c.accountNames) == 0 {
@ -109,7 +109,7 @@ func (c *addCommand) addAccountsToList(gtsClient *client.Client) error {
func (c *addCommand) addToAccount(gtsClient *client.Client) error {
funcMap := map[string]func(*client.Client) error{
noteResource: c.addNoteToAccount,
resourceNote: c.addNoteToAccount,
}
doFunc, ok := funcMap[c.resourceType]

View file

@ -24,8 +24,8 @@ func newBlockCommand(tlf topLevelFlags, name, summary string, unblock bool) *blo
unblock: unblock,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the type of resource to block or unblock")
command.StringVar(&command.accountName, accountNameFlag, "", "specify the account name in full (username@domain)")
command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to block or unblock")
command.StringVar(&command.accountName, flagAccountName, "", "specify the account name in full (username@domain)")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -34,7 +34,7 @@ func newBlockCommand(tlf topLevelFlags, name, summary string, unblock bool) *blo
func (c *blockCommand) Execute() error {
funcMap := map[string]func(*client.Client) error{
accountResource: c.blockAccount,
resourceAccount: c.blockAccount,
}
doFunc, ok := funcMap[c.resourceType]

View file

@ -24,9 +24,9 @@ func newCreateCommand(tlf topLevelFlags, name, summary string) *createCommand {
topLevelFlags: tlf,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the type of resource to create")
command.StringVar(&command.listTitle, listTitleFlag, "", "specify the title of the list")
command.StringVar(&command.listRepliesPolicy, listRepliesPolicyFlag, "list", "specify the policy of the replies for this list (valid values are followed, list and none)")
command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to create")
command.StringVar(&command.listTitle, flagListTitle, "", "specify the title of the list")
command.StringVar(&command.listRepliesPolicy, flagListRepliesPolicy, "list", "specify the policy of the replies for this list (valid values are followed, list and none)")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -35,7 +35,7 @@ func newCreateCommand(tlf topLevelFlags, name, summary string) *createCommand {
func (c *createCommand) Execute() error {
if c.resourceType == "" {
return flagNotSetError{flagText: resourceTypeFlag}
return flagNotSetError{flagText: flagType}
}
gtsClient, err := client.NewClientFromConfig(c.topLevelFlags.configDir)
@ -44,7 +44,7 @@ func (c *createCommand) Execute() error {
}
funcMap := map[string]func(*client.Client) error{
listResource: c.createList,
resourceList: c.createList,
}
doFunc, ok := funcMap[c.resourceType]
@ -57,7 +57,7 @@ func (c *createCommand) Execute() error {
func (c *createCommand) createList(gtsClient *client.Client) error {
if c.listTitle == "" {
return flagNotSetError{flagText: listTitleFlag}
return flagNotSetError{flagText: flagListTitle}
}
repliesPolicy, err := model.ParseListRepliesPolicy(c.listRepliesPolicy)

View file

@ -22,8 +22,8 @@ func newDeleteCommand(tlf topLevelFlags, name, summary string) *deleteCommand {
topLevelFlags: tlf,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the type of resource to delete")
command.StringVar(&command.listID, listIDFlag, "", "specify the ID of the list to delete")
command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to delete")
command.StringVar(&command.listID, flagListID, "", "specify the ID of the list to delete")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -32,11 +32,11 @@ func newDeleteCommand(tlf topLevelFlags, name, summary string) *deleteCommand {
func (c *deleteCommand) Execute() error {
if c.resourceType == "" {
return flagNotSetError{flagText: resourceTypeFlag}
return flagNotSetError{flagText: flagType}
}
funcMap := map[string]func(*client.Client) error{
listResource: c.deleteList,
resourceList: c.deleteList,
}
doFunc, ok := funcMap[c.resourceType]
@ -54,7 +54,7 @@ func (c *deleteCommand) Execute() error {
func (c *deleteCommand) deleteList(gtsClient *client.Client) error {
if c.listID == "" {
return flagNotSetError{flagText: listIDFlag}
return flagNotSetError{flagText: flagListID}
}
if err := gtsClient.DeleteList(c.listID); err != nil {

View file

@ -25,10 +25,10 @@ func newFollowCommand(tlf topLevelFlags, name, summary string, unfollow bool) *f
topLevelFlags: tlf,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the type of resource to follow")
command.StringVar(&command.accountName, accountNameFlag, "", "specify the account name in full (username@domain)")
command.BoolVar(&command.showReposts, showRepostsFlag, true, "show reposts from the account you want to follow")
command.BoolVar(&command.notify, notifyFlag, false, "get notifications when the account you want to follow posts a status")
command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to follow")
command.StringVar(&command.accountName, flagAccountName, "", "specify the account name in full (username@domain)")
command.BoolVar(&command.showReposts, flagShowReposts, true, "show reposts from the account you want to follow")
command.BoolVar(&command.notify, flagNotify, false, "get notifications when the account you want to follow posts a status")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -37,7 +37,7 @@ func newFollowCommand(tlf topLevelFlags, name, summary string, unfollow bool) *f
func (c *followCommand) Execute() error {
funcMap := map[string]func(*client.Client) error{
accountResource: c.followAccount,
resourceAccount: c.followAccount,
}
doFunc, ok := funcMap[c.resourceType]

View file

@ -24,7 +24,7 @@ func newLoginCommand(tlf topLevelFlags, name, summary string) *loginCommand {
instance: "",
}
command.StringVar(&command.instance, instanceFlag, "", "specify the instance that you want to login to.")
command.StringVar(&command.instance, flagInstance, "", "specify the instance that you want to login to.")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -35,7 +35,7 @@ func (c *loginCommand) Execute() error {
var err error
if c.instance == "" {
return flagNotSetError{flagText: instanceFlag}
return flagNotSetError{flagText: flagInstance}
}
instance := c.instance

View file

@ -7,37 +7,36 @@ import (
)
const (
accountNameFlag = "account-name"
addToFlag = "to"
contentFlag = "content"
instanceFlag = "instance"
limitFlag = "limit"
listIDFlag = "list-id"
listTitleFlag = "list-title"
listRepliesPolicyFlag = "list-replies-policy"
myAccountFlag = "my-account"
notifyFlag = "notify"
removeFromFlag = "from"
resourceTypeFlag = "type"
showAccountRelationshipFlag = "show-account-relationship"
showUserPreferencesFlag = "show-preferences"
showRepostsFlag = "show-reposts"
statusIDFlag = "status-id"
tagFlag = "tag"
timelineCategoryFlag = "timeline-category"
toAccountFlag = "to-account"
flagAccountName = "account-name"
flagTo = "to"
flagContent = "content"
flagInstance = "instance"
flagLimit = "limit"
flagListID = "list-id"
flagListTitle = "list-title"
flagListRepliesPolicy = "list-replies-policy"
flagMyAccount = "my-account"
flagNotify = "notify"
flagFrom = "from"
flagType = "type"
flagShowRelationship = "show-relationship"
flagShowPreferences = "show-preferences"
flagShowReposts = "show-reposts"
flagStatusID = "status-id"
flagTag = "tag"
flagTimelineCategory = "timeline-category"
)
const (
accountResource = "account"
blockedResource = "blocked"
followersResource = "followers"
followingResource = "following"
instanceResource = "instance"
listResource = "list"
noteResource = "note"
statusResource = "status"
timelineResource = "timeline"
resourceAccount = "account"
resourceBlocked = "blocked"
resourceFollowers = "followers"
resourceFollowing = "following"
resourceInstance = "instance"
resourceList = "list"
resourceNote = "note"
resourceStatus = "status"
resourceTimeline = "timeline"
)
type Executor interface {
@ -55,44 +54,44 @@ func main() {
func run() error {
const (
login string = "login"
version string = "version"
showResource string = "show"
switchAccount string = "switch"
createResource string = "create"
deleteResource string = "delete"
updateResource string = "update"
whoami string = "whoami"
add string = "add"
remove string = "remove"
follow string = "follow"
unfollow string = "unfollow"
block string = "block"
unblock string = "unblock"
commandLogin string = "login"
commandVersion string = "version"
commandShow string = "show"
commandSwitchAccount string = "switch-account"
commandCreate string = "create"
commandDelete string = "delete"
commandUpdate string = "update"
commandWhoami string = "whoami"
commandAdd string = "add"
commandRemove string = "remove"
commandFollow string = "follow"
commandUnfollow string = "unfollow"
commandBlock string = "block"
commandUnblock string = "unblock"
)
summaries := map[string]string{
login: "login to an account on GoToSocial",
version: "print the application's version and build information",
showResource: "print details about a specified resource",
switchAccount: "switch to an account",
createResource: "create a specific resource",
deleteResource: "delete a specific resource",
updateResource: "update a specific resource",
whoami: "print the account that you are currently logged in to",
add: "add a resource to another resource",
remove: "remove a resource from another resource",
follow: "follow a resource (e.g. an account)",
unfollow: "unfollow a resource (e.g. an account)",
block: "block a resource (e.g. an account)",
unblock: "unblock a resource (e.g. an account)",
commandSummaries := map[string]string{
commandLogin: "login to an account on GoToSocial",
commandVersion: "print the application's version and build information",
commandShow: "print details about a specified resource",
commandSwitchAccount: "switch to a different account",
commandCreate: "create a specific resource",
commandDelete: "delete a specific resource",
commandUpdate: "update a specific resource",
commandWhoami: "print the account that you are currently logged in to",
commandAdd: "add a resource to another resource",
commandRemove: "remove a resource from another resource",
commandFollow: "follow a resource (e.g. an account)",
commandUnfollow: "unfollow a resource (e.g. an account)",
commandBlock: "block a resource (e.g. an account)",
commandUnblock: "unblock a resource (e.g. an account)",
}
tlf := topLevelFlags{}
flag.StringVar(&tlf.configDir, "config-dir", "", "specify your config directory")
flag.Usage = enbasUsageFunc(summaries)
flag.Usage = enbasUsageFunc(commandSummaries)
flag.Parse()
@ -102,46 +101,50 @@ func run() error {
return nil
}
subcommand := flag.Arg(0)
command := flag.Arg(0)
args := flag.Args()[1:]
// TODO: will not be needed anymore
var executor Executor
switch subcommand {
case login:
executor = newLoginCommand(tlf, login, summaries[login])
case version:
executor = newVersionCommand(version, summaries[version])
case showResource:
executor = newShowCommand(tlf, showResource, summaries[showResource])
case switchAccount:
executor = newSwitchCommand(tlf, switchAccount, summaries[switchAccount])
case createResource:
executor = newCreateCommand(tlf, createResource, summaries[createResource])
case deleteResource:
executor = newDeleteCommand(tlf, deleteResource, summaries[deleteResource])
case updateResource:
executor = newUpdateCommand(tlf, updateResource, summaries[updateResource])
case whoami:
executor = newWhoAmICommand(tlf, whoami, summaries[whoami])
case add:
executor = newAddCommand(tlf, add, summaries[add])
case remove:
executor = newRemoveCommand(tlf, remove, summaries[remove])
case follow:
executor = newFollowCommand(tlf, follow, summaries[follow], false)
case unfollow:
executor = newFollowCommand(tlf, unfollow, summaries[unfollow], true)
case block:
executor = newBlockCommand(tlf, block, summaries[block], false)
case unblock:
executor = newBlockCommand(tlf, unblock, summaries[unblock], true)
switch command {
case commandLogin:
executor = newLoginCommand(tlf, commandLogin, commandSummaries[commandLogin])
case commandVersion:
executor = newVersionCommand(commandVersion, commandSummaries[commandVersion])
case commandShow:
executor = newShowCommand(tlf, commandShow, commandSummaries[commandShow])
case commandSwitchAccount:
executor = newSwitchCommand(tlf, commandSwitchAccount, commandSummaries[commandSwitchAccount])
case commandCreate:
executor = newCreateCommand(tlf, commandCreate, commandSummaries[commandCreate])
case commandDelete:
executor = newDeleteCommand(tlf, commandDelete, commandSummaries[commandDelete])
case commandUpdate:
executor = newUpdateCommand(tlf, commandUpdate, commandSummaries[commandUpdate])
case commandWhoami:
executor = newWhoAmICommand(tlf, commandWhoami, commandSummaries[commandWhoami])
case commandAdd:
executor = newAddCommand(tlf, commandAdd, commandSummaries[commandAdd])
case commandRemove:
executor = newRemoveCommand(tlf, commandRemove, commandSummaries[commandRemove])
case commandFollow:
executor = newFollowCommand(tlf, commandFollow, commandSummaries[commandFollow], false)
case commandUnfollow:
executor = newFollowCommand(tlf, commandUnfollow, commandSummaries[commandUnfollow], true)
case commandBlock:
executor = newBlockCommand(tlf, commandBlock, commandSummaries[commandBlock], false)
case commandUnblock:
executor = newBlockCommand(tlf, commandUnblock, commandSummaries[commandUnblock], true)
default:
flag.Usage()
return unknownSubcommandError{subcommand}
return unknownSubcommandError{command}
}
// To Do: create a function in executor package that will take in concrete type
// as interface and run the parse and execute command.
if err := executor.Parse(args); err != nil {
return fmt.Errorf("unable to parse the command line flags; %w", err)
}

View file

@ -26,10 +26,10 @@ func newRemoveCommand(tlf topLevelFlags, name, summary string) *removeCommand {
topLevelFlags: tlf,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the resource type to remove (e.g. account, note)")
command.StringVar(&command.fromResourceType, removeFromFlag, "", "specify the resource type to remove from (e.g. list, account, etc)")
command.StringVar(&command.listID, listIDFlag, "", "the ID of the list to remove from")
command.Var(&command.accountNames, accountNameFlag, "the name of the account to remove from the resource")
command.StringVar(&command.resourceType, flagType, "", "specify the resource type to remove (e.g. account, note)")
command.StringVar(&command.fromResourceType, flagFrom, "", "specify the resource type to remove from (e.g. list, account, etc)")
command.StringVar(&command.listID, flagListID, "", "the ID of the list to remove from")
command.Var(&command.accountNames, flagAccountName, "the name of the account to remove from the resource")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -38,12 +38,12 @@ func newRemoveCommand(tlf topLevelFlags, name, summary string) *removeCommand {
func (c *removeCommand) Execute() error {
if c.fromResourceType == "" {
return flagNotSetError{flagText: removeFromFlag}
return flagNotSetError{flagText: flagFrom}
}
funcMap := map[string]func(*client.Client) error{
listResource: c.removeFromList,
accountResource: c.removeFromAccount,
resourceList: c.removeFromList,
resourceAccount: c.removeFromAccount,
}
doFunc, ok := funcMap[c.fromResourceType]
@ -61,7 +61,7 @@ func (c *removeCommand) Execute() error {
func (c *removeCommand) removeFromList(gtsClient *client.Client) error {
funcMap := map[string]func(*client.Client) error{
accountResource: c.removeAccountsFromList,
resourceAccount: c.removeAccountsFromList,
}
doFunc, ok := funcMap[c.resourceType]
@ -77,7 +77,7 @@ func (c *removeCommand) removeFromList(gtsClient *client.Client) error {
func (c *removeCommand) removeAccountsFromList(gtsClient *client.Client) error {
if c.listID == "" {
return flagNotSetError{flagText: listIDFlag}
return flagNotSetError{flagText: flagListID}
}
if len(c.accountNames) == 0 {
@ -106,7 +106,7 @@ func (c *removeCommand) removeAccountsFromList(gtsClient *client.Client) error {
func (c *removeCommand) removeFromAccount(gtsClient *client.Client) error {
funcMap := map[string]func(*client.Client) error{
noteResource: c.removeNoteFromAccount,
resourceNote: c.removeNoteFromAccount,
}
doFunc, ok := funcMap[c.resourceType]

View file

@ -30,16 +30,16 @@ func newShowCommand(tlf topLevelFlags, name, summary string) *showCommand {
topLevelFlags: tlf,
}
command.BoolVar(&command.myAccount, myAccountFlag, false, "set to true to lookup your account")
command.BoolVar(&command.showAccountRelationship, showAccountRelationshipFlag, false, "show your relationship to the specified account")
command.BoolVar(&command.showUserPreferences, showUserPreferencesFlag, false, "show your preferences")
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the type of resource to display")
command.StringVar(&command.accountName, accountNameFlag, "", "specify the account name in full (username@domain)")
command.StringVar(&command.statusID, statusIDFlag, "", "specify the ID of the status to display")
command.StringVar(&command.timelineCategory, timelineCategoryFlag, "home", "specify the type of timeline to display (valid values are home, public, list and tag)")
command.StringVar(&command.listID, listIDFlag, "", "specify the ID of the list to display")
command.StringVar(&command.tag, tagFlag, "", "specify the name of the tag to use")
command.IntVar(&command.limit, limitFlag, 20, "specify the limit of items to display")
command.BoolVar(&command.myAccount, flagMyAccount, false, "set to true to lookup your account")
command.BoolVar(&command.showAccountRelationship, flagShowRelationship, false, "show your relationship to the specified account")
command.BoolVar(&command.showUserPreferences, flagShowPreferences, false, "show your preferences")
command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to display")
command.StringVar(&command.accountName, flagAccountName, "", "specify the account name in full (username@domain)")
command.StringVar(&command.statusID, flagStatusID, "", "specify the ID of the status to display")
command.StringVar(&command.timelineCategory, flagTimelineCategory, "home", "specify the type of timeline to display (valid values are home, public, list and tag)")
command.StringVar(&command.listID, flagListID, "", "specify the ID of the list to display")
command.StringVar(&command.tag, flagTag, "", "specify the name of the tag to use")
command.IntVar(&command.limit, flagLimit, 20, "specify the limit of items to display")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -48,18 +48,18 @@ func newShowCommand(tlf topLevelFlags, name, summary string) *showCommand {
func (c *showCommand) Execute() error {
if c.resourceType == "" {
return flagNotSetError{flagText: resourceTypeFlag}
return flagNotSetError{flagText: flagType}
}
funcMap := map[string]func(*client.Client) error{
instanceResource: c.showInstance,
accountResource: c.showAccount,
statusResource: c.showStatus,
timelineResource: c.showTimeline,
listResource: c.showList,
followersResource: c.showFollowers,
followingResource: c.showFollowing,
blockedResource: c.showBlocked,
resourceInstance: c.showInstance,
resourceAccount: c.showAccount,
resourceStatus: c.showStatus,
resourceTimeline: c.showTimeline,
resourceList: c.showList,
resourceFollowers: c.showFollowers,
resourceFollowing: c.showFollowing,
resourceBlocked: c.showBlocked,
}
doFunc, ok := funcMap[c.resourceType]
@ -99,7 +99,7 @@ func (c *showCommand) showAccount(gtsClient *client.Client) error {
}
} else {
if c.accountName == "" {
return flagNotSetError{flagText: accountNameFlag}
return flagNotSetError{flagText: flagAccountName}
}
account, err = getAccount(gtsClient, c.accountName)
@ -133,7 +133,7 @@ func (c *showCommand) showAccount(gtsClient *client.Client) error {
func (c *showCommand) showStatus(gtsClient *client.Client) error {
if c.statusID == "" {
return flagNotSetError{flagText: statusIDFlag}
return flagNotSetError{flagText: flagStatusID}
}
status, err := gtsClient.GetStatus(c.statusID)
@ -159,13 +159,13 @@ func (c *showCommand) showTimeline(gtsClient *client.Client) error {
timeline, err = gtsClient.GetPublicTimeline(c.limit)
case "list":
if c.listID == "" {
return flagNotSetError{flagText: listIDFlag}
return flagNotSetError{flagText: flagListID}
}
timeline, err = gtsClient.GetListTimeline(c.listID, c.limit)
case "tag":
if c.tag == "" {
return flagNotSetError{flagText: tagFlag}
return flagNotSetError{flagText: flagTag}
}
timeline, err = gtsClient.GetTagTimeline(c.tag, c.limit)

View file

@ -20,7 +20,7 @@ func newSwitchCommand(tlf topLevelFlags, name, summary string) *switchCommand {
topLevelFlags: tlf,
}
command.StringVar(&command.toAccount, toAccountFlag, "", "the account to switch to")
command.StringVar(&command.toAccount, flagTo, "", "the account to switch to")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -29,7 +29,7 @@ func newSwitchCommand(tlf topLevelFlags, name, summary string) *switchCommand {
func (c *switchCommand) Execute() error {
if c.toAccount == "" {
return flagNotSetError{flagText: toAccountFlag}
return flagNotSetError{flagText: flagTo}
}
if err := config.UpdateCurrentAccount(c.toAccount, c.topLevelFlags.configDir); err != nil {

View file

@ -24,10 +24,10 @@ func newUpdateCommand(tlf topLevelFlags, name, summary string) *updateCommand {
topLevelFlags: tlf,
}
command.StringVar(&command.resourceType, resourceTypeFlag, "", "specify the type of resource to update")
command.StringVar(&command.listID, listIDFlag, "", "specify the ID of the list to update")
command.StringVar(&command.listTitle, listTitleFlag, "", "specify the title of the list")
command.StringVar(&command.listRepliesPolicy, listRepliesPolicyFlag, "", "specify the policy of the replies for this list (valid values are followed, list and none)")
command.StringVar(&command.resourceType, flagType, "", "specify the type of resource to update")
command.StringVar(&command.listID, flagListID, "", "specify the ID of the list to update")
command.StringVar(&command.listTitle, flagListTitle, "", "specify the title of the list")
command.StringVar(&command.listRepliesPolicy, flagListRepliesPolicy, "", "specify the policy of the replies for this list (valid values are followed, list and none)")
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
@ -36,11 +36,11 @@ func newUpdateCommand(tlf topLevelFlags, name, summary string) *updateCommand {
func (c *updateCommand) Execute() error {
if c.resourceType == "" {
return flagNotSetError{flagText: resourceTypeFlag}
return flagNotSetError{flagText: flagType}
}
funcMap := map[string]func(*client.Client) error{
listResource: c.updateList,
resourceList: c.updateList,
}
doFunc, ok := funcMap[c.resourceType]
@ -58,7 +58,7 @@ func (c *updateCommand) Execute() error {
func (c *updateCommand) updateList(gtsClient *client.Client) error {
if c.listID == "" {
return flagNotSetError{flagText: listIDFlag}
return flagNotSetError{flagText: flagListID}
}
list, err := gtsClient.GetList(c.listID)