Skip to content

Commit

Permalink
Merge pull request #132 from Scalingo/cli_app_remotes
Browse files Browse the repository at this point in the history
Issue #129: Add of a --remote flag to create command
  • Loading branch information
Soulou committed Aug 27, 2015
2 parents 53e2620 + 24e4f16 commit e7bb5f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions appdetect/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func ScalingoRepo(directory string) (string, error) {
return "", errgo.Newf("Scalingo GIT remote hasn't been found")
}

func AddRemote(url string) error {
func AddRemote(url string, name string) error {
remote := &gitremote.Remote{
Name: "scalingo",
Name: name,
URL: url,
}

Expand Down
8 changes: 4 additions & 4 deletions apps/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
"github.com/Scalingo/cli/appdetect"
)

func Create(appName string) error {
func Create(appName string, remote string) error {
app, err := api.AppsCreate(appName)
if err != nil {
return errgo.Mask(err, errgo.Any)
}

fmt.Printf("App '%s' has been created\n", app.Name)
if _, ok := appdetect.DetectGit(); ok && appdetect.AddRemote(app.GitUrl) == nil {
fmt.Printf("Git repository detected: remote scalingo added\n→ 'git push scalingo master' to deploy your app\n")
if _, ok := appdetect.DetectGit(); ok && appdetect.AddRemote(app.GitUrl, remote) == nil {
fmt.Printf("Git repository detected: remote %s added\n→ 'git push %s master' to deploy your app\n", remote, remote)
} else {
fmt.Printf("To deploy your application, run these commands in your GIT repository:\n→ git remote add scalingo %s\n→ git push scalingo master\n", app.GitUrl)
fmt.Printf("To deploy your application, run these commands in your GIT repository:\n→ git remote add %s %s\n→ git push %s master\n", remote, app.GitUrl, remote)
}
return nil
}
5 changes: 3 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ var (
Name: "create",
Category: "Global",
ShortName: "c",
Description: "Create a new app:\n Example:\n 'scalingo create mynewapp'",
Description: "Create a new app:\n Example:\n 'scalingo create mynewapp'\n 'scalingo create mynewapp --remote \"staging\"'",
Flags: []cli.Flag{cli.StringFlag{Name: "remote", Value: "scalingo", Usage: "Remote to add to your current git repository", EnvVar: ""}},
Usage: "Create a new app",
Action: func(c *cli.Context) {
if len(c.Args()) != 1 {
cli.ShowCommandHelp(c, "create")
} else {
err := apps.Create(c.Args()[0])
err := apps.Create(c.Args()[0], c.String("remote"))
if err != nil {
errorQuit(err)
}
Expand Down

0 comments on commit e7bb5f5

Please sign in to comment.