github.com/koron/hk@v0.0.0-20150303213137-b8aeaa3ab34c/rename.go (about)

     1  package main
     2  
     3  import (
     4  	"log"
     5  	"os"
     6  
     7  	"github.com/heroku/hk/Godeps/_workspace/src/github.com/bgentry/heroku-go"
     8  )
     9  
    10  var cmdRename = &Command{
    11  	Run:      runRename,
    12  	Usage:    "rename <oldname> <newname>",
    13  	Category: "app",
    14  	Short:    "rename an app",
    15  	Long: `
    16  Rename renames a heroku app.
    17  
    18  Example:
    19  
    20      $ hk rename myapp myapp2
    21  `,
    22  }
    23  
    24  func runRename(cmd *Command, args []string) {
    25  	if len(args) != 2 {
    26  		cmd.PrintUsage()
    27  		os.Exit(2)
    28  	}
    29  	oldname, newname := args[0], args[1]
    30  	app, err := client.AppUpdate(oldname, &heroku.AppUpdateOpts{Name: &newname})
    31  	must(err)
    32  	log.Printf("Renamed %s to %s.", oldname, app.Name)
    33  	log.Println("Ensure you update your git remote URL.")
    34  	// should we automatically update the remote if they specify an app
    35  	// or via mustApp + conditional logic - RM
    36  }