mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-04 10:58:29 +02:00
migrate tea to urfave v3 (#760)
I tested this somewhat, but I haven't been using the cli before so I'm not sure if there are changes - there shouldn't be though. Reviewed-on: https://gitea.com/gitea/tea/pulls/760 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
@ -4,13 +4,14 @@
|
||||
package notifications
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
// CmdNotificationsMarkRead represents a sub command of notifications to list read notifications
|
||||
@ -21,16 +22,16 @@ var CmdNotificationsMarkRead = cli.Command{
|
||||
Description: "Mark all filtered or a specific notification as read",
|
||||
ArgsUsage: "[all | <notification id>]",
|
||||
Flags: flags.NotificationFlags,
|
||||
Action: func(ctx *cli.Context) error {
|
||||
cmd := context.InitCommand(ctx)
|
||||
filter, err := flags.NotificationStateFlag.GetValues(ctx)
|
||||
Action: func(_ stdctx.Context, cmd *cli.Command) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
filter, err := flags.NotificationStateFlag.GetValues(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !cmd.IsSet(flags.NotificationStateFlag.Name) {
|
||||
if !ctx.IsSet(flags.NotificationStateFlag.Name) {
|
||||
filter = []string{string(gitea.NotifyStatusUnread)}
|
||||
}
|
||||
return markNotificationAs(cmd, filter, gitea.NotifyStatusRead)
|
||||
return markNotificationAs(ctx, filter, gitea.NotifyStatusRead)
|
||||
},
|
||||
}
|
||||
|
||||
@ -42,16 +43,16 @@ var CmdNotificationsMarkUnread = cli.Command{
|
||||
Description: "Mark all filtered or a specific notification as unread",
|
||||
ArgsUsage: "[all | <notification id>]",
|
||||
Flags: flags.NotificationFlags,
|
||||
Action: func(ctx *cli.Context) error {
|
||||
cmd := context.InitCommand(ctx)
|
||||
filter, err := flags.NotificationStateFlag.GetValues(ctx)
|
||||
Action: func(_ stdctx.Context, cmd *cli.Command) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
filter, err := flags.NotificationStateFlag.GetValues(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !cmd.IsSet(flags.NotificationStateFlag.Name) {
|
||||
if !ctx.IsSet(flags.NotificationStateFlag.Name) {
|
||||
filter = []string{string(gitea.NotifyStatusRead)}
|
||||
}
|
||||
return markNotificationAs(cmd, filter, gitea.NotifyStatusUnread)
|
||||
return markNotificationAs(ctx, filter, gitea.NotifyStatusUnread)
|
||||
},
|
||||
}
|
||||
|
||||
@ -63,16 +64,16 @@ var CmdNotificationsMarkPinned = cli.Command{
|
||||
Description: "Mark all filtered or a specific notification as pinned",
|
||||
ArgsUsage: "[all | <notification id>]",
|
||||
Flags: flags.NotificationFlags,
|
||||
Action: func(ctx *cli.Context) error {
|
||||
cmd := context.InitCommand(ctx)
|
||||
filter, err := flags.NotificationStateFlag.GetValues(ctx)
|
||||
Action: func(_ stdctx.Context, cmd *cli.Command) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
filter, err := flags.NotificationStateFlag.GetValues(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !cmd.IsSet(flags.NotificationStateFlag.Name) {
|
||||
if !ctx.IsSet(flags.NotificationStateFlag.Name) {
|
||||
filter = []string{string(gitea.NotifyStatusUnread)}
|
||||
}
|
||||
return markNotificationAs(cmd, filter, gitea.NotifyStatusPinned)
|
||||
return markNotificationAs(ctx, filter, gitea.NotifyStatusPinned)
|
||||
},
|
||||
}
|
||||
|
||||
@ -83,11 +84,11 @@ var CmdNotificationsUnpin = cli.Command{
|
||||
Description: "Marks all pinned or a specific notification as read",
|
||||
ArgsUsage: "[all | <notification id>]",
|
||||
Flags: flags.NotificationFlags,
|
||||
Action: func(ctx *cli.Context) error {
|
||||
cmd := context.InitCommand(ctx)
|
||||
Action: func(_ stdctx.Context, cmd *cli.Command) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
filter := []string{string(gitea.NotifyStatusPinned)}
|
||||
// NOTE: we implicitly mark it as read, to match web UI semantics. marking as unread might be more useful?
|
||||
return markNotificationAs(cmd, filter, gitea.NotifyStatusRead)
|
||||
return markNotificationAs(ctx, filter, gitea.NotifyStatusRead)
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user