Skip to content

Commit 5f552cc

Browse files
authored
cli: Add version command to display CLI version (#1120)
1 parent 7f989e0 commit 5f552cc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

cli/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package cli
2+
3+
const Version = "v136"

main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Commands:
2020
dev Serve the web application in development mode with live reload
2121
2222
Options:
23-
--help Display this help message
23+
--version, -v Show the version of esm.sh CLI
24+
--help, -h Display this help message
2425
`
2526

2627
func main() {
@@ -41,7 +42,19 @@ func main() {
4142
cli.Serve(false)
4243
case "dev":
4344
cli.Serve(true)
45+
case "version":
46+
fmt.Println("esm.sh CLI " + cli.Version)
4447
default:
48+
for _, arg := range os.Args[1:] {
49+
if arg == "-v" {
50+
fmt.Println(cli.Version)
51+
return
52+
}
53+
if arg == "--version" {
54+
fmt.Println("esm.sh CLI " + cli.Version)
55+
return
56+
}
57+
}
4558
fmt.Print(helpMessage)
4659
}
4760
}

0 commit comments

Comments
 (0)