aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-04-11 01:35:58 +0700
committerShulhan <ms@kilabit.info>2024-04-11 01:35:58 +0700
commit7e89b8cac03c30280b3f323a2eaf5eb613f15e02 (patch)
tree9ec8f2e7ef0da7e7dcd75c1a4ea7730b651bae6a /cmd
parent9beac0837d5284212728b7556165110344ef5773 (diff)
downloadciigo-7e89b8cac03c30280b3f323a2eaf5eb613f15e02.tar.xz
cmd/ciigo: add flag to set package and variable name for "embed"
The flag "-package-name" can be used to changes the default package name inside the Go embed file. The flag "-var-name" can be used to changes the default memfs variable name inside the Go embed file.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ciigo/main.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/ciigo/main.go b/cmd/ciigo/main.go
index 53c35f0..9b5184d 100644
--- a/cmd/ciigo/main.go
+++ b/cmd/ciigo/main.go
@@ -36,6 +36,7 @@ import (
"strings"
"git.sr.ht/~shulhan/ciigo"
+ "git.sr.ht/~shulhan/pakakeh.go/lib/memfs"
)
const (
@@ -64,6 +65,9 @@ func main() {
exclude = flag.String("exclude", "",
"a regex to exclude certain paths from being scanned during covert, embeded, watch, or serve")
+ var flagPackageName = flag.String(`package-name`, `main`, `package name for embed`)
+ var flagVarName = flag.String(`var-name`, `memFS`, `variable name for embed`)
+
flag.Parse()
var (
@@ -89,10 +93,14 @@ func main() {
err = ciigo.Convert(&convertOpts)
case cmdEmbed:
- var embedOpts ciigo.EmbedOptions
-
- embedOpts.ConvertOptions = convertOpts
- embedOpts.EmbedOptions.GoFileName = *outputFile
+ var embedOpts = ciigo.EmbedOptions{
+ ConvertOptions: convertOpts,
+ EmbedOptions: memfs.EmbedOptions{
+ GoFileName: *outputFile,
+ PackageName: *flagPackageName,
+ VarName: *flagVarName,
+ },
+ }
err = ciigo.GoEmbed(&embedOpts)
@@ -139,12 +147,16 @@ ciigo help
Print the usage (this output).
-ciigo [-template <file>] [-exclude <regex>] [-out <file>] embed <dir>
+ciigo [-template <file>] [-exclude <regex>] [-out <file>]
+ [-package-name <string>] [-var-name <string>]
+ embed <dir>
Convert all markup files inside directory "dir" recursively and then
embed them into ".go" source file.
The output file is optional, default to "ciigo_static.go" in current
directory.
+ The package name default to main.
+ The variable name default to memFS.
ciigo [-template <file>] [-exclude <regex>] [-address <ip:port>] serve <dir>