aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-15 21:24:29 +0700
committerShulhan <ms@kilabit.info>2026-01-15 21:24:29 +0700
commit095cee86d92b2e69419caaa5d83e7cbf92e38a83 (patch)
tree2efd2e1173ba916f9331f3f0615008546126fb3c
parentaa7f2df15e91f5c94807247228cf82e18fe03887 (diff)
downloadspdxconv-095cee86d92b2e69419caaa5d83e7cbf92e38a83.tar.xz
config: use embed for spdxconv.cfg template
Using embed made it easy to edit and review the code.
-rw-r--r--config.go70
-rw-r--r--spdxconv.cfg.template67
2 files changed, 70 insertions, 67 deletions
diff --git a/config.go b/config.go
index 00164ba..04e5b31 100644
--- a/config.go
+++ b/config.go
@@ -4,78 +4,14 @@
package spdxconv
import (
+ _ "embed"
"errors"
"git.sr.ht/~shulhan/pakakeh.go/lib/ini"
)
-var configTemplate string = `# SPDX-License-Identifier: CC0-1.0
-# SPDX-FileCopyrightText: 2026 M. Shulhan <ms@kilabit.info>
-
-[default]
-license_identifier =
-copyright_year =
-file_copyright_text =
-max_line_match = 10
-
-[match-file-comment]
-pattern = "^.*\\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx)$"
-pattern = "^.*\\.(jsonc|kt|kts|php|rs|sass|scss|swift|ts|tsx)$"
-pattern = "^(.*/)?(go.mod|go.work)$"
-prefix = "//"
-
-[match-file-comment]
-pattern = "^.*\\.(aff|aww|bash|csh|d2|dockerfile|env|gitignore|gitmodules|hcl|ipynb)$"
-pattern = "^.*\\.(make|pl|pm|py|ps1|rb|sh|tf|toml|yaml|yml|zsh)$"
-pattern = "^(.*/)?([Dd]ockerfile|[Mm]akefile|robots.txt)$"
-# systemd.unit(5).
-pattern = "^.*\\.(automount|device|mount|path|scope|service|slice|socket|swap|target|timer)$"
-prefix = "#"
-
-[match-file-comment]
-pattern = "^.*\\.(css)$"
-prefix = "/*"
-suffix = "*/"
-
-[match-file-comment]
-pattern = "^.*\\.(fxml|gohtml|htm|html|html5|kml|markdown|md|xml)$"
-prefix = "<!--"
-suffix = "-->"
-
-[match-file-comment]
-pattern = "^.*\\.(lua|sql)$"
-prefix = "--"
-
-[match-file-comment]
-pattern = "^.*\\.(rst)$"
-prefix = ".."
-
-[match-file-comment]
-pattern = "^.*\\.(tex)$"
-prefix = "%"
-
-# File name that match with this pattern will have the ".license" file
-# created.
-[match-file-comment]
-pattern = "^.*\\.(apk|app|bz2|exe|gz|tar|tgz|zip)$"
-pattern = "^.*\\.(csv|doc|docx|json|pdf|ppt|pptx|xls|xlsx)$"
-pattern = "^.*\\.(bmp|gif|ico|jpeg|jpg|png|svg|svgz|webp)$"
-pattern = "^.*\\.(3gp|avi|flv|mkv|mp3|mp4|mpeg|mpg|mpg4)$"
-pattern = "^.*\\.(acc|ogg|mp3)$"
-pattern = "^(.*/)?(go.sum|go.work.sum)$"
-
-[match-license]
-pattern = "^(//+|#+|/\\*+|<!--+|--+)?\\s*(.*)governed by a BSD-style(.*)$"
-license_identifier = BSD-3-Clause
-delete_line_before = "^(//+|#+|/\\*+|<!--+|--+)$"
-delete_line_after = "^(//+|#+|/\\*+|<!--+|--+)?\\s*license that can(.*)$"
-delete_line_after = "^(//+|#+|\\*+/|--+>|--+)$"
-
-[match-copyright]
-pattern = "^(//+|#+|/\\*+|<!--+|--+)?\\s*Copyright\\s+(?<year>\\d{4}),?\\s+(?<author>.*)\\s+<(?<contact>.*)>.*$"
-delete_line_before = "^(//+|#+|/\\*+|<!--+|--+)$"
-delete_line_after = "^(//+|#+|\\*+/|--+>|--+)$"
-`
+//go:embed spdxconv.cfg.template
+var configTemplate string
type config struct {
LicenseIdentifier string `ini:"default::license_identifier"`
diff --git a/spdxconv.cfg.template b/spdxconv.cfg.template
new file mode 100644
index 0000000..0f3484e
--- /dev/null
+++ b/spdxconv.cfg.template
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2026 M. Shulhan <ms@kilabit.info>
+
+[default]
+license_identifier =
+copyright_year =
+file_copyright_text =
+max_line_match = 10
+
+[match-file-comment]
+pattern = "^.*\\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx)$"
+pattern = "^.*\\.(jsonc|kt|kts|php|rs|sass|scss|swift|ts|tsx)$"
+pattern = "^(.*/)?(go.mod|go.work)$"
+prefix = "//"
+
+[match-file-comment]
+pattern = "^.*\\.(aff|aww|bash|csh|d2|dockerfile|env|gitignore|gitmodules)$"
+pattern = "^.*\\.(hcl|ipynb|make|pl|pm|py|ps1|rb|sh|tf|toml|yaml|yml|zsh)$"
+pattern = "^(.*/)?([Dd]ockerfile|[Mm]akefile|robots.txt)$"
+# systemd.unit(5).
+pattern = "^.*\\.(automount|device|mount|path|scope|service|slice|socket|swap|target|timer)$"
+prefix = "#"
+
+[match-file-comment]
+pattern = "^.*\\.(css)$"
+prefix = "/*"
+suffix = "*/"
+
+[match-file-comment]
+pattern = "^.*\\.(fxml|gohtml|htm|html|html5|kml|markdown|md|xml)$"
+prefix = "<!--"
+suffix = "-->"
+
+[match-file-comment]
+pattern = "^.*\\.(lua|sql)$"
+prefix = "--"
+
+[match-file-comment]
+pattern = "^.*\\.(rst)$"
+prefix = ".."
+
+[match-file-comment]
+pattern = "^.*\\.(tex)$"
+prefix = "%"
+
+# File name that match with this pattern will have the ".license" file
+# created.
+[match-file-comment]
+pattern = "^.*\\.(apk|app|bz2|exe|gz|tar|tgz|zip)$"
+pattern = "^.*\\.(csv|doc|docx|json|pdf|ppt|pptx|xls|xlsx)$"
+pattern = "^.*\\.(bmp|gif|ico|jpeg|jpg|png|svg|svgz|webp)$"
+pattern = "^.*\\.(3gp|avi|flv|mkv|mp3|mp4|mpeg|mpg|mpg4)$"
+pattern = "^.*\\.(acc|ogg|mp3)$"
+pattern = "^(.*/)?(go.sum|go.work.sum)$"
+
+[match-license]
+pattern = "^(//+|#+|/\\*+|<!--+|--+)?\\s*(.*)governed by a BSD-style(.*)$"
+license_identifier = BSD-3-Clause
+delete_line_before = "^(//+|#+|/\\*+|<!--+|--+)$"
+delete_line_after = "^(//+|#+|/\\*+|<!--+|--+)?\\s*license that can(.*)$"
+delete_line_after = "^(//+|#+|\\*+/|--+>|--+)$"
+
+[match-copyright]
+pattern = "^(//+|#+|/\\*+|<!--+|--+)?\\s*Copyright\\s+(?<year>\\d{4}),?\\s+(?<author>.*)\\s+<(?<contact>.*)>.*$"
+delete_line_before = "^(//+|#+|/\\*+|<!--+|--+)$"
+delete_line_after = "^(//+|#+|\\*+/|--+>|--+)$"
+