2019-10-23 11:58:18 -04:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2023-09-07 21:40:02 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-10-23 11:58:18 -04:00
|
|
|
|
2020-09-30 01:11:33 -04:00
|
|
|
package flags
|
2019-10-23 11:58:18 -04:00
|
|
|
|
|
|
|
import (
|
2020-01-04 12:44:25 -05:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-10-23 11:58:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// LoginFlag provides flag to specify tea login profile
|
|
|
|
var LoginFlag = cli.StringFlag{
|
2020-12-15 12:38:22 -05:00
|
|
|
Name: "login",
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
Usage: "Use a different Gitea Login. Optional",
|
2019-10-23 11:58:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// RepoFlag provides flag to specify repository
|
|
|
|
var RepoFlag = cli.StringFlag{
|
2020-12-15 12:38:22 -05:00
|
|
|
Name: "repo",
|
|
|
|
Aliases: []string{"r"},
|
|
|
|
Usage: "Override local repository path or gitea repository slug to interact with. Optional",
|
2019-10-23 11:58:18 -04:00
|
|
|
}
|
|
|
|
|
2019-10-26 17:29:37 -04:00
|
|
|
// RemoteFlag provides flag to specify remote repository
|
|
|
|
var RemoteFlag = cli.StringFlag{
|
2020-12-15 12:38:22 -05:00
|
|
|
Name: "remote",
|
|
|
|
Aliases: []string{"R"},
|
|
|
|
Usage: "Discover Gitea login from remote. Optional",
|
2019-10-26 17:29:37 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 11:58:18 -04:00
|
|
|
// OutputFlag provides flag to specify output type
|
|
|
|
var OutputFlag = cli.StringFlag{
|
2020-12-15 12:38:22 -05:00
|
|
|
Name: "output",
|
|
|
|
Aliases: []string{"o"},
|
2022-09-27 11:39:47 -04:00
|
|
|
Usage: "Output format. (simple, table, csv, tsv, yaml, json)",
|
2019-10-23 11:58:18 -04:00
|
|
|
}
|
|
|
|
|
2020-09-27 08:07:46 -04:00
|
|
|
// PaginationPageFlag provides flag for pagination options
|
|
|
|
var PaginationPageFlag = cli.StringFlag{
|
|
|
|
Name: "page",
|
|
|
|
Aliases: []string{"p"},
|
|
|
|
Usage: "specify page, default is 1",
|
|
|
|
}
|
|
|
|
|
|
|
|
// PaginationLimitFlag provides flag for pagination options
|
|
|
|
var PaginationLimitFlag = cli.StringFlag{
|
|
|
|
Name: "limit",
|
|
|
|
Aliases: []string{"lm"},
|
|
|
|
Usage: "specify limit of items per page",
|
|
|
|
}
|
|
|
|
|
2019-10-23 11:58:18 -04:00
|
|
|
// LoginOutputFlags defines login and output flags that should
|
|
|
|
// added to all subcommands and appended to the flags of the
|
|
|
|
// subcommand to work around issue and provide --login and --output:
|
|
|
|
// https://github.com/urfave/cli/issues/585
|
|
|
|
var LoginOutputFlags = []cli.Flag{
|
2020-01-04 12:44:25 -05:00
|
|
|
&LoginFlag,
|
|
|
|
&OutputFlag,
|
2019-10-23 11:58:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// LoginRepoFlags defines login and repo flags that should
|
|
|
|
// be used for all subcommands and appended to the flags of
|
|
|
|
// the subcommand to work around issue and provide --login and --repo:
|
|
|
|
// https://github.com/urfave/cli/issues/585
|
|
|
|
var LoginRepoFlags = []cli.Flag{
|
2020-01-04 12:44:25 -05:00
|
|
|
&LoginFlag,
|
|
|
|
&RepoFlag,
|
|
|
|
&RemoteFlag,
|
2019-10-23 11:58:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// AllDefaultFlags defines flags that should be available
|
|
|
|
// for all subcommands working with dedicated repositories
|
|
|
|
// to work around issue and provide --login, --repo and --output:
|
|
|
|
// https://github.com/urfave/cli/issues/585
|
|
|
|
var AllDefaultFlags = append([]cli.Flag{
|
2020-01-04 12:44:25 -05:00
|
|
|
&RepoFlag,
|
|
|
|
&RemoteFlag,
|
2019-10-23 11:58:18 -04:00
|
|
|
}, LoginOutputFlags...)
|
|
|
|
|
2021-09-05 13:11:17 -04:00
|
|
|
// NotificationFlags defines flags that should be available on notifications.
|
|
|
|
var NotificationFlags = append([]cli.Flag{
|
|
|
|
NotificationStateFlag,
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "mine",
|
|
|
|
Aliases: []string{"m"},
|
|
|
|
Usage: "Show notifications across all your repositories instead of the current repository only",
|
|
|
|
},
|
|
|
|
&PaginationPageFlag,
|
|
|
|
&PaginationLimitFlag,
|
|
|
|
}, AllDefaultFlags...)
|
|
|
|
|
|
|
|
// NotificationStateFlag is a csv flag applied to all notification subcommands as filter
|
|
|
|
var NotificationStateFlag = NewCsvFlag(
|
|
|
|
"states",
|
|
|
|
"notification states to filter by",
|
|
|
|
[]string{"s"},
|
|
|
|
[]string{"pinned", "unread", "read"},
|
|
|
|
[]string{"unread", "pinned"},
|
|
|
|
)
|
|
|
|
|
2020-12-21 10:41:07 -05:00
|
|
|
// FieldsFlag generates a flag selecting printable fields.
|
2021-09-05 13:11:17 -04:00
|
|
|
// To retrieve the value, use f.GetValues()
|
|
|
|
func FieldsFlag(availableFields, defaultFields []string) *CsvFlag {
|
|
|
|
return NewCsvFlag("fields", "fields to print", []string{"f"}, availableFields, defaultFields)
|
2020-12-21 10:41:07 -05:00
|
|
|
}
|