aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-04-03 04:36:37 +0700
committerShulhan <ms@kilabit.info>2021-04-03 04:40:28 +0700
commit158e76e2c1c6ae2d42ba141e87130f29da142560 (patch)
tree646d7024d0112d73145bd4cea9d916bba6baebb3 /cmd
parentbabb6b16261ffa6a5931223c95316487048ce4d8 (diff)
downloadciigo-158e76e2c1c6ae2d42ba141e87130f29da142560.tar.xz
all: add option to exclude certain paths using regular expression
The ConvertOptions now has the Exclude field that can contains regular expression. If the Exclude is not empty, it will be compiled and use in Convert, Generate, Watch, and Serve; to ignore specific paths being scanned.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ciigo/main.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/cmd/ciigo/main.go b/cmd/ciigo/main.go
index 69c7231..5e3339c 100644
--- a/cmd/ciigo/main.go
+++ b/cmd/ciigo/main.go
@@ -10,20 +10,20 @@
//
// The following section describe how to use ciigo CLI.
//
-// ciigo [-template <file>] convert <dir>
+// ciigo [-template <file>] [-exclude <regex>] convert <dir>
//
// Scan the "dir" recursively to find markup files and convert them into HTML
// files.
// The template "file" is optional, default to embedded HTML template.
//
-// ciigo [-template <file>] [-out <file>] generate <dir>
+// ciigo [-template <file>] [-exclude <regex>] [-out <file>] generate <dir>
//
// Convert all the 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.
//
-// ciigo [-template <file>] [-address <ip:port>] serve <dir>
+// ciigo [-template <file>] [-exclude <regex>] [-address <ip:port>] serve <dir>
//
// Serve all files inside directory "dir" using HTTP server, watch changes on
// markup files and convert them to HTML files.
@@ -50,6 +50,8 @@ func main() {
"path to output of .go generated file")
address := flag.String("address", ":8080",
"the binding address for HTTP server")
+ exclude := flag.String("exclude", "",
+ "a regex to exclude certain paths from being scanned during covert, generate, watch, or serve")
flag.Parse()
@@ -77,6 +79,7 @@ func main() {
opts := ciigo.ConvertOptions{
Root: dir,
HtmlTemplate: *htmlTemplate,
+ Exclude: *exclude,
}
err = ciigo.Convert(&opts)
@@ -85,6 +88,7 @@ func main() {
ConvertOptions: ciigo.ConvertOptions{
Root: dir,
HtmlTemplate: *htmlTemplate,
+ Exclude: *exclude,
},
GenGoFileName: *outputFile,
}
@@ -96,6 +100,7 @@ func main() {
ConvertOptions: ciigo.ConvertOptions{
Root: dir,
HtmlTemplate: *htmlTemplate,
+ Exclude: *exclude,
},
Address: *address,
}
@@ -119,20 +124,20 @@ files, as HTML files.
== Usage
-ciigo [-template <file>] convert <dir>
+ciigo [-template <file>] [-exclude <regex>] convert <dir>
Scan the "dir" recursively to find markup files.
and convert them into HTML files.
The template "file" is optional, default to embedded HTML template.
-ciigo [-template <file>] [-out <file>] generate <dir>
+ciigo [-template <file>] [-exclude <regex>] [-out <file>] generate <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.
-ciigo [-template <file>] [-address <ip:port>] serve <dir>
+ciigo [-template <file>] [-exclude <regex>] [-address <ip:port>] serve <dir>
Serve all files inside directory "dir" using HTTP server, watch
changes on markup files and convert them to HTML files automatically.