BREAKING CHANGE: The original Go module name was `github.com/ArtalkJS/Artalk`, which has now been modified to `github.com/artalkjs/artalk/v2` (all lowercase). This change may affect the CI pipeline or other areas if you are compiling the Artalk server and have specified the fixed Go module name. Regarding the original `-ldflags -X github.com/ArtalkJS/Artalk/internal/config.Version` and `CommitHash` definitions, please remove them, as they are now obsolete. The `Version` has been hardcoded into the Go code, and the `CommitHash` is now read from the Go build info via runtime/debug’s vcs.revision value. This change only affects the server developers and does not impact the frontend UI client.
35 lines
776 B
Go
35 lines
776 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/artalkjs/artalk/v2/internal/core"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func NewGenCommand() *cobra.Command {
|
|
genCmd := &cobra.Command{
|
|
Use: "gen <TYPE> <DEST>",
|
|
Short: "A collection of several useful generators",
|
|
Long: "Generate some content\ne.g. `artalk gen config ./artalk.yml`",
|
|
Args: cobra.RangeArgs(1, 2),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
var (
|
|
specificPath string
|
|
isForce bool
|
|
)
|
|
if len(args) > 1 {
|
|
specificPath = args[1]
|
|
}
|
|
isForce, _ = cmd.Flags().GetBool("force")
|
|
|
|
core.Gen(args[0], specificPath, isForce)
|
|
},
|
|
Annotations: map[string]string{
|
|
BootModeKey: MODE_MINI_BOOT,
|
|
},
|
|
}
|
|
|
|
flagPV(genCmd, "force", "f", false, "Force overwrite an existing file")
|
|
|
|
return genCmd
|
|
}
|