From 38cef79652548736a339ec1d838cf66b6a9d9a61 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 19 May 2022 17:40:34 +0700 Subject: cmd/ciigo: add command to print to current version --- cmd/ciigo/main.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/cmd/ciigo/main.go b/cmd/ciigo/main.go index 0f19f55..e8bec17 100644 --- a/cmd/ciigo/main.go +++ b/cmd/ciigo/main.go @@ -39,6 +39,15 @@ import ( "github.com/shuLhan/share/lib/memfs" ) +const ( + cmdConvert = "convert" + cmdEmbed = "embed" + cmdServe = "serve" + cmdVersion = "version" + + version = "0.8.1" +) + func main() { flag.Usage = usage isHelp := flag.Bool("help", false, "print help") @@ -73,7 +82,7 @@ func main() { command = strings.ToLower(command) switch command { - case "convert": + case cmdConvert: opts := ciigo.ConvertOptions{ Root: dir, HtmlTemplate: *htmlTemplate, @@ -81,7 +90,7 @@ func main() { } err = ciigo.Convert(&opts) - case "embed": + case cmdEmbed: genOpts := ciigo.EmbedOptions{ ConvertOptions: ciigo.ConvertOptions{ Root: dir, @@ -94,7 +103,7 @@ func main() { } err = ciigo.GoEmbed(&genOpts) - case "serve": + case cmdServe: opts := ciigo.ServeOptions{ ConvertOptions: ciigo.ConvertOptions{ Root: dir, @@ -106,6 +115,9 @@ func main() { } err = ciigo.Serve(&opts) + case cmdVersion: + fmt.Println(version) + default: usage() os.Exit(1) @@ -141,5 +153,9 @@ ciigo [-template ] [-exclude ] [-address ] serve Serve all files inside directory "dir" using HTTP server, watch changes on markup files and convert them to HTML files automatically. - If the address is not set, its default to ":8080".`) + If the address is not set, its default to ":8080". + +ciigo version + + Print the current ciigo version.`) } -- cgit v1.3