cmd

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllDefaultFlags = append([]cli.Flag{
	&RepoFlag,
	&RemoteFlag,
}, LoginOutputFlags...)

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

View Source
var CmdIssues = cli.Command{
	Name:        "issues",
	Usage:       "List and create issues",
	Description: `List and create issues`,
	ArgsUsage:   "[<issue index>]",
	Action:      runIssues,
	Subcommands: []*cli.Command{
		&CmdIssuesList,
		&CmdIssuesCreate,
		&CmdIssuesReopen,
		&CmdIssuesClose,
	},
	Flags: AllDefaultFlags,
}

CmdIssues represents to login a gitea server.

View Source
var CmdIssuesClose = cli.Command{
	Name:        "close",
	Usage:       "Change state of an issue to 'closed'",
	Description: `Change state of an issue to 'closed'`,
	ArgsUsage:   "<issue index>",
	Action: func(ctx *cli.Context) error {
		var s = gitea.StateClosed
		return editIssueState(ctx, gitea.EditIssueOption{State: &s})
	},
	Flags: AllDefaultFlags,
}

CmdIssuesClose represents a sub command of issues to close an issue

View Source
var CmdIssuesCreate = cli.Command{
	Name:        "create",
	Usage:       "Create an issue on repository",
	Description: `Create an issue on repository`,
	Action:      runIssuesCreate,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:    "title",
			Aliases: []string{"t"},
			Usage:   "issue title to create",
		},
		&cli.StringFlag{
			Name:    "body",
			Aliases: []string{"b"},
			Usage:   "issue body to create",
		},
	}, LoginRepoFlags...),
}

CmdIssuesCreate represents a sub command of issues to create issue

View Source
var CmdIssuesList = cli.Command{
	Name:        "ls",
	Usage:       "List issues of the repository",
	Description: `List issues of the repository`,
	Action:      runIssuesList,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:        "state",
			Usage:       "Filter by issue state (all|open|closed)",
			DefaultText: "open",
		},
	}, AllDefaultFlags...),
}

CmdIssuesList represents a sub command of issues to list issues

View Source
var CmdIssuesReopen = cli.Command{
	Name:        "reopen",
	Aliases:     []string{"open"},
	Usage:       "Change state of an issue to 'open'",
	Description: `Change state of an issue to 'open'`,
	ArgsUsage:   "<issue index>",
	Action: func(ctx *cli.Context) error {
		var s = gitea.StateOpen
		return editIssueState(ctx, gitea.EditIssueOption{State: &s})
	},
	Flags: AllDefaultFlags,
}

CmdIssuesReopen represents a sub command of issues to open an issue

View Source
var CmdLabelCreate = cli.Command{
	Name:        "create",
	Usage:       "Create a label",
	Description: `Create a label`,
	Action:      runLabelCreate,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "name",
			Usage: "label name",
		},
		&cli.StringFlag{
			Name:  "color",
			Usage: "label color value",
		},
		&cli.StringFlag{
			Name:  "description",
			Usage: "label description",
		},
		&cli.StringFlag{
			Name:  "file",
			Usage: "indicate a label file",
		},
	},
}

CmdLabelCreate represents a sub command of labels to create label.

View Source
var CmdLabelDelete = cli.Command{
	Name:        "delete",
	Usage:       "Delete a label",
	Description: `Delete a label`,
	Action:      runLabelCreate,
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:  "id",
			Usage: "label id",
		},
	},
}

CmdLabelDelete represents a sub command of labels to delete label.

View Source
var CmdLabelUpdate = cli.Command{
	Name:        "update",
	Usage:       "Update a label",
	Description: `Update a label`,
	Action:      runLabelUpdate,
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:  "id",
			Usage: "label id",
		},
		&cli.StringFlag{
			Name:  "name",
			Usage: "label name",
		},
		&cli.StringFlag{
			Name:  "color",
			Usage: "label color value",
		},
		&cli.StringFlag{
			Name:  "description",
			Usage: "label description",
		},
	},
}

CmdLabelUpdate represents a sub command of labels to update label.

View Source
var CmdLabels = cli.Command{
	Name:        "labels",
	Usage:       "Manage issue labels",
	Description: `Manage issue labels`,
	Action:      runLabels,
	Subcommands: []*cli.Command{
		&CmdLabelCreate,
		&CmdLabelUpdate,
		&CmdLabelDelete,
	},
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:    "save",
			Aliases: []string{"s"},
			Usage:   "Save all the labels as a file",
		},
	}, AllDefaultFlags...),
}

CmdLabels represents to operate repositories' labels.

View Source
var CmdLogin = cli.Command{
	Name:        "login",
	Usage:       "Log in to a Gitea server",
	Description: `Log in to a Gitea server`,
	Action:      runLoginList,
	Subcommands: []*cli.Command{
		&cmdLoginList,
		&cmdLoginAdd,
	},
}

CmdLogin represents to login a gitea server.

View Source
var CmdLogout = cli.Command{
	Name:        "logout",
	Usage:       "Log out from a Gitea server",
	Description: `Log out from a Gitea server`,
	Action:      runLogout,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "name",
			Aliases: []string{"n"},
			Usage:   "Login name to remove",
		},
	},
}

CmdLogout represents to logout a gitea server.

View Source
var CmdNotifications = cli.Command{
	Name:        "notifications",
	Usage:       "show notifications",
	Description: "show notifications, by default based of the current repo and unread one",
	Action:      runNotifications,
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:    "all",
			Aliases: []string{"a"},
			Usage:   "show all notifications of related gitea instance",
		},

		&cli.IntFlag{
			Name:    "page",
			Aliases: []string{"p"},
			Usage:   "specify page, default is 1",
			Value:   1,
		},
		&cli.IntFlag{
			Name:    "limit",
			Aliases: []string{"lm"},
			Usage:   "specify limit of items per page",
		},
	}, AllDefaultFlags...),
}

CmdNotifications is the main command to operate with notifications

View Source
var CmdOpen = cli.Command{
	Name:        "open",
	Usage:       "Open something of the repository on web browser",
	Description: `Open something of the repository on web browser`,
	Action:      runOpen,
	Flags:       append([]cli.Flag{}, LoginRepoFlags...),
}

CmdOpen represents a sub command of issues to open issue on the web browser

View Source
var CmdPulls = cli.Command{
	Name:        "pulls",
	Aliases:     []string{"pull", "pr"},
	Usage:       "List open pull requests",
	Description: `List open pull requests`,
	Action:      runPulls,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:        "state",
			Usage:       "Filter by PR state (all|open|closed)",
			DefaultText: "open",
		},
	}, AllDefaultFlags...),
	Subcommands: []*cli.Command{
		&CmdPullsCheckout,
		&CmdPullsClean,
		&CmdPullsCreate,
	},
}

CmdPulls is the main command to operate on PRs

View Source
var CmdPullsCheckout = cli.Command{
	Name:        "checkout",
	Usage:       "Locally check out the given PR",
	Description: `Locally check out the given PR`,
	Action:      runPullsCheckout,
	ArgsUsage:   "<pull index>",
	Flags:       AllDefaultFlags,
}

CmdPullsCheckout is a command to locally checkout the given PR

View Source
var CmdPullsClean = cli.Command{
	Name:        "clean",
	Usage:       "Deletes local & remote feature-branches for a closed pull request",
	Description: `Deletes local & remote feature-branches for a closed pull request`,
	ArgsUsage:   "<pull index>",
	Action:      runPullsClean,
	Flags: append([]cli.Flag{
		&cli.BoolFlag{
			Name:  "ignore-sha",
			Usage: "Find the local branch by name instead of commit hash (less precise)",
		},
	}, AllDefaultFlags...),
}

CmdPullsClean removes the remote and local feature branches, if a PR is merged.

View Source
var CmdPullsCreate = cli.Command{
	Name:        "create",
	Usage:       "Create a pull-request",
	Description: "Create a pull-request",
	Action:      runPullsCreate,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:  "head",
			Usage: "Set head branch (default is current one)",
		},
		&cli.StringFlag{
			Name:    "base",
			Aliases: []string{"b"},
			Usage:   "Set base branch (default is default branch)",
		},
		&cli.StringFlag{
			Name:    "title",
			Aliases: []string{"t"},
			Usage:   "Set title of pull (default is head branch name)",
		},
		&cli.StringFlag{
			Name:    "description",
			Aliases: []string{"d"},
			Usage:   "Set body of new pull",
		},
	}, AllDefaultFlags...),
}

CmdPullsCreate creates a pull request

View Source
var CmdReleaseCreate = cli.Command{
	Name:        "create",
	Usage:       "Create a release",
	Description: `Create a release`,
	Action:      runReleaseCreate,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:  "tag",
			Usage: "Tag name",
		},
		&cli.StringFlag{
			Name:  "target",
			Usage: "Target refs, branch name or commit id",
		},
		&cli.StringFlag{
			Name:    "title",
			Aliases: []string{"t"},
			Usage:   "Release title",
		},
		&cli.StringFlag{
			Name:    "note",
			Aliases: []string{"n"},
			Usage:   "Release notes",
		},
		&cli.BoolFlag{
			Name:    "draft",
			Aliases: []string{"d"},
			Usage:   "Is a draft",
		},
		&cli.BoolFlag{
			Name:    "prerelease",
			Aliases: []string{"p"},
			Usage:   "Is a pre-release",
		},
		&cli.StringSliceFlag{
			Name:    "asset",
			Aliases: []string{"a"},
			Usage:   "List of files to attach",
		},
	}, LoginRepoFlags...),
}

CmdReleaseCreate represents a sub command of Release to create release.

View Source
var CmdReleases = cli.Command{
	Name:        "releases",
	Usage:       "Create releases",
	Description: `Create releases`,
	Action:      runReleases,
	Subcommands: []*cli.Command{
		&CmdReleaseCreate,
	},
	Flags: AllDefaultFlags,
}

CmdReleases represents to login a gitea server.

View Source
var CmdRepos = cli.Command{
	Name:        "repos",
	Usage:       "Operate with repositories",
	Description: `Operate with repositories`,
	Action:      runReposList,
	Subcommands: []*cli.Command{
		&CmdReposList,
	},
	Flags: LoginOutputFlags,
}

CmdRepos represents to login a gitea server.

View Source
var CmdReposList = cli.Command{
	Name:        "ls",
	Usage:       "List available repositories",
	Description: `List available repositories`,
	Action:      runReposList,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:  "mode",
			Usage: "Filter listed repositories based on mode, optional - fork, mirror, source",
		},
		&cli.StringFlag{
			Name:  "org",
			Usage: "Filter listed repositories based on organization, optional",
		},
		&cli.StringFlag{
			Name:  "user",
			Usage: "Filter listed repositories absed on user, optional",
		},
	}, LoginOutputFlags...),
}

CmdReposList represents a sub command of issues to list issues

View Source
var CmdTrackedTimes = cli.Command{
	Name:    "times",
	Aliases: []string{"time"},
	Usage:   "Operate on tracked times of a repository's issues & pulls",
	Description: `Operate on tracked times of a repository's issues & pulls.
		 Depending on your permissions on the repository, only your own tracked
		 times might be listed.`,
	ArgsUsage: "[username | #issue]",
	Action:    runTrackedTimes,
	Subcommands: []*cli.Command{
		&CmdTrackedTimesAdd,
		&CmdTrackedTimesDelete,
		&CmdTrackedTimesReset,
	},
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:    "from",
			Aliases: []string{"f"},
			Usage:   "Show only times tracked after this date",
		},
		&cli.StringFlag{
			Name:    "until",
			Aliases: []string{"u"},
			Usage:   "Show only times tracked before this date",
		},
		&cli.BoolFlag{
			Name:    "total",
			Aliases: []string{"t"},
			Usage:   "Print the total duration at the end",
		},
	}, AllDefaultFlags...),
}

CmdTrackedTimes represents the command to operate repositories' times.

View Source
var CmdTrackedTimesAdd = cli.Command{
	Name:      "add",
	Usage:     "Track spent time on an issue",
	UsageText: "tea times add <issue> <duration>",
	Description: `Track spent time on an issue
	 Example:
		tea times add 1 1h25m
	`,
	Action: runTrackedTimesAdd,
	Flags:  LoginRepoFlags,
}

CmdTrackedTimesAdd represents a sub command of times to add time to an issue

View Source
var CmdTrackedTimesDelete = cli.Command{
	Name:      "delete",
	Aliases:   []string{"rm"},
	Usage:     "Delete a single tracked time on an issue",
	UsageText: "tea times delete <issue> <time ID>",
	Action:    runTrackedTimesDelete,
	Flags:     LoginRepoFlags,
}

CmdTrackedTimesDelete is a sub command of CmdTrackedTimes, and removes time from an issue

View Source
var CmdTrackedTimesReset = cli.Command{
	Name:      "reset",
	Usage:     "Reset tracked time on an issue",
	UsageText: "tea times reset <issue>",
	Action:    runTrackedTimesReset,
	Flags:     LoginRepoFlags,
}

CmdTrackedTimesReset is a subcommand of CmdTrackedTimes, and clears all tracked times on an issue.

View Source
var LoginFlag = cli.StringFlag{
	Name:        "login",
	Aliases:     []string{"l"},
	Usage:       "Use a different Gitea login. Optional",
	Destination: &loginValue,
}

LoginFlag provides flag to specify tea login profile

View Source
var LoginOutputFlags = []cli.Flag{
	&LoginFlag,
	&OutputFlag,
}

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

View Source
var LoginRepoFlags = []cli.Flag{
	&LoginFlag,
	&RepoFlag,
	&RemoteFlag,
}

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

View Source
var OutputFlag = cli.StringFlag{
	Name:        "output",
	Aliases:     []string{"o"},
	Usage:       "Output format. (csv, simple, table, tsv, yaml)",
	Destination: &outputValue,
}

OutputFlag provides flag to specify output type

View Source
var RemoteFlag = cli.StringFlag{
	Name:        "remote",
	Aliases:     []string{"R"},
	Usage:       "Discover Gitea login from remote. Optional",
	Destination: &remoteValue,
}

RemoteFlag provides flag to specify remote repository

View Source
var RepoFlag = cli.StringFlag{
	Name:        "repo",
	Aliases:     []string{"r"},
	Usage:       "Repository to interact with. Optional",
	Destination: &repoValue,
}

RepoFlag provides flag to specify repository

Functions

func Error

func Error(a ...interface{})

Error println content as an error information

func Errorf

func Errorf(format string, a ...interface{})

Errorf printf content as an error information

func Output

func Output(output string, headers []string, values [][]string)

Output provides general function to convert given information into several outputs

func Printf

func Printf(format string, a ...interface{})

Printf printf content according the flag

func Println

func Println(a ...interface{})

Println println content according the flag

Types

type Config

type Config struct {
	Logins []Login `yaml:"logins"`
}

Config reprensents local configurations

type Login

type Login struct {
	Name    string `yaml:"name"`
	URL     string `yaml:"url"`
	Token   string `yaml:"token"`
	Active  bool   `yaml:"active"`
	SSHHost string `yaml:"ssh_host"`
	// optional path to the private key
	SSHKey   string `yaml:"ssh_key"`
	Insecure bool   `yaml:"insecure"`
	// optional gitea username
	User string `yaml:"user"`
}

Login represents a login to a gitea server, you even could add multiple logins for one gitea server

func (*Login) Client

func (l *Login) Client() *gitea.Client

Client returns a client to operate Gitea API

func (*Login) GetSSHHost

func (l *Login) GetSSHHost() string

GetSSHHost returns SSH host name

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL