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