Skip to content

Commit

Permalink
Merge pull request #79 from revel/develop
Browse files Browse the repository at this point in the history
v0.14.1
  • Loading branch information
brendensoares committed Mar 25, 2017
2 parents da79330 + 0f47be7 commit 95d6366
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions revel/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package main

import (
"go/build"
"strconv"
"strings"

"github.com/revel/cmd/harness"
"github.com/revel/revel"
Expand Down Expand Up @@ -65,14 +65,18 @@ func parseRunArgs(args []string) *RunArgs {
// 1. revel run [import-path] [run-mode]
// 2. revel run [import-path] [port]
// 3. revel run [run-mode] [port]
if strings.Contains(args[0], "/") {
if _, err := build.Import(args[0], "", build.FindOnly); err == nil {
// 1st arg is the import path
inputArgs.ImportPath = args[0]
if port, err := strconv.Atoi(args[1]); err == nil {
// 2nd arg is the port number
inputArgs.Port = port
} else {
// 2nd arg is the run mode
inputArgs.Mode = args[1]
}
} else {
// 1st arg is the run mode
port, err := strconv.Atoi(args[1])
if err != nil {
errorf("Failed to parse port as integer: %s", args[1])
Expand All @@ -85,12 +89,14 @@ func parseRunArgs(args []string) *RunArgs {
// 1. revel run [import-path]
// 2. revel run [port]
// 3. revel run [run-mode]
if strings.Contains(args[0], "/") ||
strings.Contains(inputArgs.ImportPath, "..") {
if _, err := build.Import(args[0], "", build.FindOnly); err == nil {
// 1st arg is the import path
inputArgs.ImportPath = args[0]
} else if port, err := strconv.Atoi(args[0]); err == nil {
// 1st arg is the port number
inputArgs.Port = port
} else {
// 1st arg is the run mode
inputArgs.Mode = args[0]
}
}
Expand Down

0 comments on commit 95d6366

Please sign in to comment.