<commit_before>// Copyright 2017 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.

package client

import (
	"github.com/keybase/cli"
	"github.com/keybase/client/go/libcmdline"
	"github.com/keybase/client/go/libkb"
	keybase1 "github.com/keybase/client/go/protocol/keybase1"
	"github.com/keybase/go-framed-msgpack-rpc/rpc"
	"golang.org/x/net/context"
)

type CmdTeamCreate struct {
	TeamName  keybase1.TeamName
	SessionID int
	libkb.Contextified
}

func (v *CmdTeamCreate) ParseArgv(ctx *cli.Context) error {
	var err error
	v.TeamName, err = ParseOneTeamNameK1(ctx)
	if err != nil {
		return err
	}

	return nil
}

func (v *CmdTeamCreate) Run() (err error) {
	cli, err := GetTeamsClient(v.G())
	if err != nil {
		return err
	}

	dui := v.G().UI.GetDumbOutputUI()
	protocols := []rpc.Protocol{
		NewSecretUIProtocol(v.G()),
	}
	if err = RegisterProtocolsWithContext(protocols, v.G()); err != nil {
		return err
	}

	if v.TeamName.IsRootTeam() {
		err = cli.TeamCreate(context.TODO(), keybase1.TeamCreateArg{
			Name:      v.TeamName,
			SessionID: v.SessionID,
		})
		if err != nil {
			return err
		}
		dui.Printf("Success!\n")
		return nil
	}

	err = cli.TeamCreateSubteam(context.TODO(), keybase1.TeamCreateSubteamArg{
		Name:      v.TeamName,
		SessionID: v.SessionID,
	})
	if err != nil {
		return err
	}
	dui.Printf("Success!\n")
	dui.Printf("NOTE: you can adminster %s, but you won't see its files or chats\n", v.TeamName)
	dui.Printf("unless you add yourself explicitly with `keybase team add-member`.\n")

	return nil
}

func newCmdTeamCreate(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
	return cli.Command{
		Name:         "create",
		ArgumentHelp: "teamname",
		Usage:        "Create a team or a subteam.",
		Flags: []cli.Flag{
			cli.BoolFlag{
				Name:  "subteam",
				Usage: "Create a subteam",
			},
		},
		Action: func(c *cli.Context) {
			cl.ChooseCommand(NewCmdTeamCreateRunner(g), "teamcreate", c)
		},
		Description: "Create a team or a subteam with specified name.",
	}
}

func NewCmdTeamCreateRunner(g *libkb.GlobalContext) *CmdTeamCreate {
	return &CmdTeamCreate{Contextified: libkb.NewContextified(g)}
}

func (v *CmdTeamCreate) GetUsage() libkb.Usage {
	return libkb.Usage{
		Config:    true,
		API:       true,
		KbKeyring: true,
	}
}
<commit_msg>Fix cli.Command fields<commit_after>// Copyright 2017 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.

package client

import (
	"github.com/keybase/cli"
	"github.com/keybase/client/go/libcmdline"
	"github.com/keybase/client/go/libkb"
	keybase1 "github.com/keybase/client/go/protocol/keybase1"
	"github.com/keybase/go-framed-msgpack-rpc/rpc"
	"golang.org/x/net/context"
)

type CmdTeamCreate struct {
	TeamName  keybase1.TeamName
	SessionID int
	libkb.Contextified
}

func (v *CmdTeamCreate) ParseArgv(ctx *cli.Context) error {
	var err error
	v.TeamName, err = ParseOneTeamNameK1(ctx)
	if err != nil {
		return err
	}

	return nil
}

func (v *CmdTeamCreate) Run() (err error) {
	cli, err := GetTeamsClient(v.G())
	if err != nil {
		return err
	}

	dui := v.G().UI.GetDumbOutputUI()
	protocols := []rpc.Protocol{
		NewSecretUIProtocol(v.G()),
	}
	if err = RegisterProtocolsWithContext(protocols, v.G()); err != nil {
		return err
	}

	if v.TeamName.IsRootTeam() {
		err = cli.TeamCreate(context.TODO(), keybase1.TeamCreateArg{
			Name:      v.TeamName,
			SessionID: v.SessionID,
		})
		if err != nil {
			return err
		}
		dui.Printf("Success!\n")
		return nil
	}

	err = cli.TeamCreateSubteam(context.TODO(), keybase1.TeamCreateSubteamArg{
		Name:      v.TeamName,
		SessionID: v.SessionID,
	})
	if err != nil {
		return err
	}
	dui.Printf("Success!\n")
	dui.Printf("NOTE: you can adminster %s, but you won't see its files or chats\n", v.TeamName)
	dui.Printf("unless you add yourself explicitly with `keybase team add-member`.\n")

	return nil
}

func newCmdTeamCreate(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
	return cli.Command{
		Name:         "create",
		ArgumentHelp: "<team name>",
		Usage:        "Create a team or a subteam.",
		Action: func(c *cli.Context) {
			cl.ChooseCommand(NewCmdTeamCreateRunner(g), "create", c)
		},
		Description: "Create a team or a subteam with specified name.",
	}
}

func NewCmdTeamCreateRunner(g *libkb.GlobalContext) *CmdTeamCreate {
	return &CmdTeamCreate{Contextified: libkb.NewContextified(g)}
}

func (v *CmdTeamCreate) GetUsage() libkb.Usage {
	return libkb.Usage{
		Config:    true,
		API:       true,
		KbKeyring: true,
	}
}

{'fraction_non_alphanumeric': 0.13298565840938723, 'fraction_numerical': 0.004345936549326379, 'mean_word_length': 3.7699481865284974, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2857477', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1695, 'n_words': 400}