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

     1  // Copyright 2019 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  // CmdSimpleFSConflicts is the 'fs clear-conflicts' command.
    17  type CmdSimpleFSClearConflicts struct {
    18  	libkb.Contextified
    19  	path keybase1.Path
    20  }
    21  
    22  // NewCmdSimpleFSClearConflicts creates a new cli.Command.
    23  func NewCmdSimpleFSClearConflicts(
    24  	cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
    25  	return cli.Command{
    26  		Name:         "clear-conflicts",
    27  		ArgumentHelp: "<path-to-folder>",
    28  		Usage:        "moves the conflict state of the given folder out of the way",
    29  		Action: func(c *cli.Context) {
    30  			cl.ChooseCommand(&CmdSimpleFSClearConflicts{
    31  				Contextified: libkb.NewContextified(g)}, "clear-conflicts", c)
    32  			cl.SetNoStandalone()
    33  		},
    34  	}
    35  }
    36  
    37  // Run runs the command in client/server mode.
    38  func (c *CmdSimpleFSClearConflicts) Run() error {
    39  	cli, err := GetSimpleFSClient(c.G())
    40  	if err != nil {
    41  		return err
    42  	}
    43  
    44  	return cli.SimpleFSClearConflictState(context.TODO(), c.path)
    45  }
    46  
    47  // ParseArgv gets the path.
    48  func (c *CmdSimpleFSClearConflicts) ParseArgv(ctx *cli.Context) error {
    49  	if len(ctx.Args()) != 1 {
    50  		return fmt.Errorf("wrong number of arguments")
    51  	}
    52  
    53  	p, err := makeSimpleFSPath(ctx.Args()[0])
    54  	if err != nil {
    55  		return err
    56  	}
    57  	c.path = p
    58  	return nil
    59  }
    60  
    61  // GetUsage says what this command needs to operate.
    62  func (c *CmdSimpleFSClearConflicts) GetUsage() libkb.Usage {
    63  	return libkb.Usage{
    64  		Config:    true,
    65  		KbKeyring: true,
    66  		API:       true,
    67  	}
    68  }