From 72f614b40e6986e49683656ace07f0fa12944953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Sun, 20 Aug 2023 21:51:12 +0800 Subject: [PATCH] U: upgrade command-line tool --- cmd/energy/energy.go | 3 +++ cmd/internal/build.go | 17 +++++++++++++++++ cmd/internal/command.go | 14 +++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cmd/energy/energy.go b/cmd/energy/energy.go index 98b4b4f8..89fd22bf 100644 --- a/cmd/energy/energy.go +++ b/cmd/energy/energy.go @@ -25,6 +25,7 @@ var commands = []*internal.Command{ internal.CmdSetenv, internal.CmdEnv, internal.CmdCreate, + internal.CmdBuild, } func main() { @@ -52,6 +53,8 @@ func main() { cc.Index = 5 case "create": cc.Index = 6 + case "build": + cc.Index = 7 } command := commands[cc.Index] if len(extraArgs) < 1 || extraArgs[len(extraArgs)-1] != "." { diff --git a/cmd/internal/build.go b/cmd/internal/build.go index b358dd84..0c4731dc 100644 --- a/cmd/internal/build.go +++ b/cmd/internal/build.go @@ -11,3 +11,20 @@ // 构建编译 energy 项目 package internal + +var CmdBuild = &Command{ + UsageLine: "build", + Short: "build energy project", + Long: ` + Building energy project + . Execute default command +`, +} + +func init() { + CmdBuild.Run = runBuild +} + +func runBuild(c *CommandConfig) error { + return nil +} diff --git a/cmd/internal/command.go b/cmd/internal/command.go index f8fbe668..ded62c72 100644 --- a/cmd/internal/command.go +++ b/cmd/internal/command.go @@ -19,6 +19,12 @@ type CommandConfig struct { Setenv Setenv `command:"setenv"` Env Env `command:"env"` Create Create `command:"create"` + Build Build `command:"build"` +} + +type Command struct { + Run func(c *CommandConfig) error + UsageLine, Short, Long string } type Install struct { @@ -46,10 +52,8 @@ type Version struct { All bool `short:"a" long:"all" description:"show all"` } -type Command struct { - Run func(c *CommandConfig) error - UsageLine, Short, Long string -} - type Create struct { } + +type Build struct { +}