mirror of
https://gitea.com/gitea/tea.git
synced 2025-06-15 18:30:22 +02:00

I tested this somewhat, but I haven't been using the cli before so I'm not sure if there are changes - there shouldn't be though. Reviewed-on: https://gitea.com/gitea/tea/pulls/760 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
stdctx "context"
|
|
|
|
"code.gitea.io/tea/cmd/organizations"
|
|
"code.gitea.io/tea/modules/context"
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
"github.com/urfave/cli/v3"
|
|
)
|
|
|
|
// CmdOrgs represents handle organization
|
|
var CmdOrgs = cli.Command{
|
|
Name: "organizations",
|
|
Aliases: []string{"organization", "org"},
|
|
Category: catEntities,
|
|
Usage: "List, create, delete organizations",
|
|
Description: "Show organization details",
|
|
ArgsUsage: "[<organization>]",
|
|
Action: runOrganizations,
|
|
Commands: []*cli.Command{
|
|
&organizations.CmdOrganizationList,
|
|
&organizations.CmdOrganizationCreate,
|
|
&organizations.CmdOrganizationDelete,
|
|
},
|
|
Flags: organizations.CmdOrganizationList.Flags,
|
|
}
|
|
|
|
func runOrganizations(ctx stdctx.Context, cmd *cli.Command) error {
|
|
teaCtx := context.InitCommand(cmd)
|
|
if teaCtx.Args().Len() == 1 {
|
|
return runOrganizationDetail(teaCtx)
|
|
}
|
|
return organizations.RunOrganizationList(ctx, cmd)
|
|
}
|
|
|
|
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
|
|
}
|