2020-12-07 06:02:50 +08:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/tea/cmd/organizations"
|
2021-09-29 04:32:16 +08:00
|
|
|
"code.gitea.io/tea/modules/context"
|
|
|
|
"code.gitea.io/tea/modules/print"
|
2020-12-07 06:02:50 +08:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdOrgs represents handle organization
|
|
|
|
var CmdOrgs = cli.Command{
|
|
|
|
Name: "organizations",
|
|
|
|
Aliases: []string{"organization", "org"},
|
2020-12-21 21:37:20 +08:00
|
|
|
Category: catEntities,
|
2020-12-07 06:02:50 +08:00
|
|
|
Usage: "List, create, delete organizations",
|
|
|
|
Description: "Show organization details",
|
|
|
|
ArgsUsage: "[<organization>]",
|
|
|
|
Action: runOrganizations,
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
&organizations.CmdOrganizationList,
|
2021-09-29 04:32:16 +08:00
|
|
|
&organizations.CmdOrganizationCreate,
|
2020-12-07 20:24:04 +08:00
|
|
|
&organizations.CmdOrganizationDelete,
|
2020-12-07 06:02:50 +08:00
|
|
|
},
|
2021-05-13 02:32:20 +08:00
|
|
|
Flags: organizations.CmdOrganizationList.Flags,
|
2020-12-07 06:02:50 +08:00
|
|
|
}
|
|
|
|
|
2021-09-29 04:32:16 +08:00
|
|
|
func runOrganizations(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
2020-12-07 06:02:50 +08:00
|
|
|
if ctx.Args().Len() == 1 {
|
2021-09-29 04:32:16 +08:00
|
|
|
return runOrganizationDetail(ctx)
|
2020-12-07 06:02:50 +08:00
|
|
|
}
|
2021-09-29 04:32:16 +08:00
|
|
|
return organizations.RunOrganizationList(cmd)
|
2020-12-07 06:02:50 +08:00
|
|
|
}
|
|
|
|
|
2021-09-29 04:32:16 +08:00
|
|
|
func runOrganizationDetail(ctx *context.TeaContext) error {
|
|
|
|
org, _, err := ctx.Login.Client().GetOrg(ctx.Args().First())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
print.OrganizationDetails(org)
|
|
|
|
return nil
|
2020-12-07 06:02:50 +08:00
|
|
|
}
|