2020-12-06 22:02:50 +00:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2023-09-08 01:40:02 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-12-06 22:02:50 +00:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/tea/cmd/organizations"
|
2021-09-28 20:32:16 +00:00
|
|
|
"code.gitea.io/tea/modules/context"
|
|
|
|
"code.gitea.io/tea/modules/print"
|
2020-12-06 22:02:50 +00:00
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdOrgs represents handle organization
|
|
|
|
var CmdOrgs = cli.Command{
|
|
|
|
Name: "organizations",
|
|
|
|
Aliases: []string{"organization", "org"},
|
2020-12-21 13:37:20 +00:00
|
|
|
Category: catEntities,
|
2020-12-06 22:02:50 +00:00
|
|
|
Usage: "List, create, delete organizations",
|
|
|
|
Description: "Show organization details",
|
|
|
|
ArgsUsage: "[<organization>]",
|
|
|
|
Action: runOrganizations,
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
&organizations.CmdOrganizationList,
|
2021-09-28 20:32:16 +00:00
|
|
|
&organizations.CmdOrganizationCreate,
|
2020-12-07 12:24:04 +00:00
|
|
|
&organizations.CmdOrganizationDelete,
|
2020-12-06 22:02:50 +00:00
|
|
|
},
|
2021-05-12 18:32:20 +00:00
|
|
|
Flags: organizations.CmdOrganizationList.Flags,
|
2020-12-06 22:02:50 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 20:32:16 +00:00
|
|
|
func runOrganizations(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
2020-12-06 22:02:50 +00:00
|
|
|
if ctx.Args().Len() == 1 {
|
2021-09-28 20:32:16 +00:00
|
|
|
return runOrganizationDetail(ctx)
|
2020-12-06 22:02:50 +00:00
|
|
|
}
|
2021-09-28 20:32:16 +00:00
|
|
|
return organizations.RunOrganizationList(cmd)
|
2020-12-06 22:02:50 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 20:32:16 +00: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-06 22:02:50 +00:00
|
|
|
}
|