github.com/knoebber/dotfile@v1.0.6/cli/remove.go (about)

     1  package cli
     2  
     3  import "gopkg.in/alecthomas/kingpin.v2"
     4  
     5  type removeCommand struct {
     6  	alias string
     7  }
     8  
     9  func (rc *removeCommand) run(*kingpin.ParseContext) error {
    10  	s, err := loadFile(rc.alias)
    11  	if err != nil {
    12  		return err
    13  	}
    14  
    15  	return s.Remove()
    16  }
    17  
    18  func addRemoveSubCommandToApplication(app *kingpin.Application) {
    19  	rc := new(removeCommand)
    20  
    21  	p := app.Command("rm", "remove the tracked file and all its data").Action(rc.run)
    22  	p.Arg("alias", "the file to remove").HintAction(flags.defaultAliasList).Required().StringVar(&rc.alias)
    23  }