mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Restructured command config
Removed go/build reference in clean
This commit is contained in:
10
model/command/build.go
Normal file
10
model/command/build.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package command
|
||||
type (
|
||||
Build struct {
|
||||
ImportCommand
|
||||
TargetPath string `short:"t" long:"target-path" description:"Path to target folder. Folder will be completely deleted if it exists" required:"false"`
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
CopySource bool `short:"s" long:"include-source" description:"Copy the source code as well"`
|
||||
}
|
||||
|
||||
)
|
||||
6
model/command/clean.go
Normal file
6
model/command/clean.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package command
|
||||
type (
|
||||
Clean struct {
|
||||
ImportCommand
|
||||
}
|
||||
)
|
||||
7
model/command/import_command.go
Normal file
7
model/command/import_command.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package command
|
||||
|
||||
type (
|
||||
ImportCommand struct {
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
}
|
||||
)
|
||||
11
model/command/new.go
Normal file
11
model/command/new.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package command
|
||||
type (
|
||||
New struct {
|
||||
ImportCommand
|
||||
SkeletonPath string `short:"s" long:"skeleton" description:"Path to skeleton folder (Must exist on GO PATH)" required:"false"`
|
||||
Package string `short:"p" long:"package" description:"The package name, this becomes the repfix to the app name, if defined vendored is set to true" required:"false"`
|
||||
NotVendored bool `short:"V" long:"vendor" description:"True if project should not be configured with a go.mod"`
|
||||
Run bool `short:"r" long:"run" description:"True if you want to run the application right away"`
|
||||
}
|
||||
|
||||
)
|
||||
9
model/command/package.go
Normal file
9
model/command/package.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package command
|
||||
type (
|
||||
Package struct {
|
||||
ImportCommand
|
||||
TargetPath string `short:"t" long:"target-path" description:"Full path and filename of target package to deploy" required:"false"`
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
CopySource bool `short:"s" long:"include-source" description:"Copy the source code as well"`
|
||||
}
|
||||
)
|
||||
9
model/command/run.go
Normal file
9
model/command/run.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package command
|
||||
type (
|
||||
Run struct {
|
||||
ImportCommand
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
Port int `short:"p" long:"port" default:"-1" description:"The port to listen" `
|
||||
NoProxy bool `short:"n" long:"no-proxy" description:"True if proxy server should not be started. This will only update the main and routes files on change"`
|
||||
}
|
||||
)
|
||||
9
model/command/test_command.go
Normal file
9
model/command/test_command.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package command
|
||||
|
||||
type (
|
||||
Test struct {
|
||||
ImportCommand
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
Function string `short:"f" long:"suite-function" description:"The suite.function"`
|
||||
}
|
||||
)
|
||||
7
model/command/version.go
Normal file
7
model/command/version.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package command
|
||||
type (
|
||||
Version struct {
|
||||
ImportCommand
|
||||
Update bool `short:"u" long:"Update the framework and modules" required:"false"`
|
||||
}
|
||||
)
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"github.com/revel/cmd/model/command"
|
||||
)
|
||||
|
||||
// The constants
|
||||
@@ -48,50 +49,20 @@ type (
|
||||
Vendored bool // True if the application is vendored
|
||||
PackageResolver func(pkgName string) error // a packge resolver for the config
|
||||
BuildFlags []string `short:"X" long:"build-flags" description:"These flags will be used when building the application. May be specified multiple times, only applicable for Build, Run, Package, Test commands"`
|
||||
// The new command
|
||||
New struct {
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
SkeletonPath string `short:"s" long:"skeleton" description:"Path to skeleton folder (Must exist on GO PATH)" required:"false"`
|
||||
Package string `short:"p" long:"package" description:"The package name, this becomes the repfix to the app name, if defined vendored is set to true" required:"false"`
|
||||
NotVendored bool `short:"V" long:"vendor" description:"True if project should not be configured with a go.mod"`
|
||||
Run bool `short:"r" long:"run" description:"True if you want to run the application right away"`
|
||||
} `command:"new"`
|
||||
|
||||
New command.New `command:"new"` // The new command
|
||||
// The build command
|
||||
Build struct {
|
||||
TargetPath string `short:"t" long:"target-path" description:"Path to target folder. Folder will be completely deleted if it exists" required:"false"`
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
CopySource bool `short:"s" long:"include-source" description:"Copy the source code as well"`
|
||||
} `command:"build"`
|
||||
Build command.Build `command:"build"`
|
||||
// The run command
|
||||
Run struct {
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
Port int `short:"p" long:"port" default:"-1" description:"The port to listen" `
|
||||
NoProxy bool `short:"n" long:"no-proxy" description:"True if proxy server should not be started. This will only update the main and routes files on change"`
|
||||
} `command:"run"`
|
||||
Run command.Run `command:"run"`
|
||||
// The package command
|
||||
Package struct {
|
||||
TargetPath string `short:"t" long:"target-path" description:"Full path and filename of target package to deploy" required:"false"`
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
CopySource bool `short:"s" long:"include-source" description:"Copy the source code as well"`
|
||||
} `command:"package"`
|
||||
Package command.Package `command:"package"`
|
||||
// The clean command
|
||||
Clean struct {
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
} `command:"clean"`
|
||||
Clean command.Clean `command:"clean"`
|
||||
// The test command
|
||||
Test struct {
|
||||
Mode string `short:"m" long:"run-mode" description:"The mode to run the application in"`
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
Function string `short:"f" long:"suite-function" description:"The suite.function"`
|
||||
} `command:"test"`
|
||||
Test command.Test `command:"test"`
|
||||
// The version command
|
||||
Version struct {
|
||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
||||
Update bool `short:"u" long:"Update the framework and modules" required:"false"`
|
||||
} `command:"version"`
|
||||
Version command.Version `command:"version"`
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/revel/cmd/model"
|
||||
"github.com/revel/cmd/utils"
|
||||
"go/build"
|
||||
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@@ -50,14 +50,10 @@ func updateCleanConfig(c *model.CommandConfig, args []string) bool {
|
||||
|
||||
// Clean the source directory of generated files
|
||||
func cleanApp(c *model.CommandConfig) (err error) {
|
||||
appPkg, err := build.Import(c.ImportPath, "", build.FindOnly)
|
||||
if err != nil {
|
||||
utils.Logger.Fatal("Abort: Failed to find import path:", "error", err)
|
||||
}
|
||||
|
||||
purgeDirs := []string{
|
||||
filepath.Join(appPkg.Dir, "app", "tmp"),
|
||||
filepath.Join(appPkg.Dir, "app", "routes"),
|
||||
filepath.Join(c.AppPath, "app", "tmp"),
|
||||
filepath.Join(c.AppPath, "app", "routes"),
|
||||
}
|
||||
|
||||
for _, dir := range purgeDirs {
|
||||
|
||||
Reference in New Issue
Block a user