mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Updated so revel new works and revel run starts parsing the source.
This commit is contained in:
24
revel/new.go
24
revel/new.go
@@ -46,14 +46,23 @@ func init() {
|
||||
// Called when unable to parse the command line automatically and assumes an old launch
|
||||
func updateNewConfig(c *model.CommandConfig, args []string) bool {
|
||||
c.Index = model.NEW
|
||||
if len(c.New.Package)>0 {
|
||||
c.New.NotVendored = false
|
||||
}
|
||||
c.Vendored = !c.New.NotVendored
|
||||
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintf(os.Stderr, cmdNew.Long)
|
||||
return false
|
||||
if len(c.New.ImportPath)==0 {
|
||||
fmt.Fprintf(os.Stderr, cmdNew.Long)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
c.New.ImportPath = args[0]
|
||||
if len(args) > 1 {
|
||||
c.New.SkeletonPath = args[1]
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
@@ -76,10 +85,6 @@ func newApp(c *model.CommandConfig) (err error) {
|
||||
return utils.NewBuildError("Abort: Unable to create app path.", "path", c.AppPath)
|
||||
}
|
||||
|
||||
if len(c.New.Package)>0 {
|
||||
c.New.Vendored = true
|
||||
}
|
||||
|
||||
// checking and setting application
|
||||
if err = setApplicationPath(c); err != nil {
|
||||
return err
|
||||
@@ -93,8 +98,9 @@ func newApp(c *model.CommandConfig) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Rerun the dep tool if vendored
|
||||
if c.New.Vendored {
|
||||
// Run the vendor tool if needed
|
||||
println("********** here",c.Vendored)
|
||||
if c.Vendored {
|
||||
if err=createModVendor(c); err!=nil {
|
||||
return
|
||||
}
|
||||
@@ -199,7 +205,7 @@ func setApplicationPath(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
|
||||
// If we are running a vendored version of Revel we do not need to check for it.
|
||||
if !c.New.Vendored {
|
||||
if !c.Vendored {
|
||||
_, err = build.Import(model.RevelImportPath, "", build.FindOnly)
|
||||
if err != nil {
|
||||
//// Go get the revel project
|
||||
|
||||
@@ -142,13 +142,10 @@ func ParseArgs(c *model.CommandConfig, parser *flags.Parser, args []string) (err
|
||||
}
|
||||
}
|
||||
|
||||
if len(extraArgs) > 0 {
|
||||
utils.Logger.Info("Found additional arguements, setting them")
|
||||
if !Commands[c.Index].UpdateConfig(c, extraArgs) {
|
||||
buffer := &bytes.Buffer{}
|
||||
parser.WriteHelp(buffer)
|
||||
err = fmt.Errorf("Invalid command line arguements %v\n%s", extraArgs, buffer.String())
|
||||
}
|
||||
if !Commands[c.Index].UpdateConfig(c, extraArgs) {
|
||||
buffer := &bytes.Buffer{}
|
||||
parser.WriteHelp(buffer)
|
||||
err = fmt.Errorf("Invalid command line arguements %v\n%s", extraArgs, buffer.String())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -106,7 +106,9 @@ func updateRunConfig(c *model.CommandConfig, args []string) bool {
|
||||
}
|
||||
case 0:
|
||||
// Attempt to set the import path to the current working director.
|
||||
c.Run.ImportPath,_ = os.Getwd()
|
||||
if c.Run.ImportPath=="" {
|
||||
c.Run.ImportPath, _ = os.Getwd()
|
||||
}
|
||||
}
|
||||
c.Index = model.RUN
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user