github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/client/cmd_git_mddel.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package client
     5  
     6  import (
     7  	"context"
     8  	"fmt"
     9  
    10  	"github.com/keybase/cli"
    11  	"github.com/keybase/client/go/libcmdline"
    12  	"github.com/keybase/client/go/libkb"
    13  	"github.com/keybase/client/go/protocol/keybase1"
    14  )
    15  
    16  type CmdGitMddel struct {
    17  	libkb.Contextified
    18  	folder   string
    19  	repoName string
    20  }
    21  
    22  // NewCmdGitMddel creates a new cli.Command.
    23  func NewCmdGitMddel(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
    24  	return cli.Command{
    25  		Name:         "mddel",
    26  		Usage:        "Delete repo metadata",
    27  		ArgumentHelp: "<folder> <reponame>",
    28  		Action: func(c *cli.Context) {
    29  			cl.ChooseCommand(&CmdGitMddel{Contextified: libkb.NewContextified(g)}, "mddel", c)
    30  		},
    31  	}
    32  }
    33  
    34  // RunClient runs the command in client/server mode.
    35  func (c *CmdGitMddel) Run() error {
    36  	cli, err := GetGitClient(c.G())
    37  	if err != nil {
    38  		return err
    39  	}
    40  
    41  	folder, err := ParseTLF(c.folder)
    42  	if err != nil {
    43  		return err
    44  	}
    45  
    46  	return cli.DeleteGitMetadata(context.Background(), keybase1.DeleteGitMetadataArg{
    47  		Folder:   folder,
    48  		RepoName: keybase1.GitRepoName(c.repoName),
    49  	})
    50  }
    51  
    52  // ParseArgv gets the secret phrase from the command args.
    53  func (c *CmdGitMddel) ParseArgv(ctx *cli.Context) error {
    54  	if len(ctx.Args()) != 2 {
    55  		return fmt.Errorf("mddel takes two arguments")
    56  	}
    57  	c.folder = ctx.Args()[0]
    58  	c.repoName = ctx.Args()[1]
    59  	return nil
    60  }
    61  
    62  // GetUsage says what this command needs to operate.
    63  func (c *CmdGitMddel) GetUsage() libkb.Usage {
    64  	return libkb.Usage{
    65  		Config:    true,
    66  		KbKeyring: true,
    67  		API:       true,
    68  	}
    69  }