mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-20 22:25:09 +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"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"github.com/revel/cmd/model/command"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The constants
|
// The constants
|
||||||
@@ -48,50 +49,20 @@ type (
|
|||||||
Vendored bool // True if the application is vendored
|
Vendored bool // True if the application is vendored
|
||||||
PackageResolver func(pkgName string) error // a packge resolver for the config
|
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"`
|
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 {
|
New command.New `command:"new"` // The new command
|
||||||
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"`
|
|
||||||
// The build command
|
// The build command
|
||||||
Build struct {
|
Build command.Build `command:"build"`
|
||||||
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"`
|
|
||||||
// The run command
|
// The run command
|
||||||
Run struct {
|
Run command.Run `command:"run"`
|
||||||
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"`
|
|
||||||
// The package command
|
// The package command
|
||||||
Package struct {
|
Package command.Package `command:"package"`
|
||||||
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"`
|
|
||||||
// The clean command
|
// The clean command
|
||||||
Clean struct {
|
Clean command.Clean `command:"clean"`
|
||||||
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
|
|
||||||
} `command:"clean"`
|
|
||||||
// The test command
|
// The test command
|
||||||
Test struct {
|
Test command.Test `command:"test"`
|
||||||
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"`
|
|
||||||
// The version command
|
// The version command
|
||||||
Version struct {
|
Version command.Version `command:"version"`
|
||||||
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"`
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/revel/cmd/model"
|
"github.com/revel/cmd/model"
|
||||||
"github.com/revel/cmd/utils"
|
"github.com/revel/cmd/utils"
|
||||||
"go/build"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
@@ -50,14 +50,10 @@ func updateCleanConfig(c *model.CommandConfig, args []string) bool {
|
|||||||
|
|
||||||
// Clean the source directory of generated files
|
// Clean the source directory of generated files
|
||||||
func cleanApp(c *model.CommandConfig) (err error) {
|
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{
|
purgeDirs := []string{
|
||||||
filepath.Join(appPkg.Dir, "app", "tmp"),
|
filepath.Join(c.AppPath, "app", "tmp"),
|
||||||
filepath.Join(appPkg.Dir, "app", "routes"),
|
filepath.Join(c.AppPath, "app", "routes"),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dir := range purgeDirs {
|
for _, dir := range purgeDirs {
|
||||||
|
|||||||
Reference in New Issue
Block a user