aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..962b0ad
--- /dev/null
+++ b/config.go
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info>
+
+package spdxconv
+
+import "errors"
+
+type config struct {
+ LicenseIdentifier string `ini:"default::license_identifier"`
+ FileCopyrightText string `ini:"default::file_copyright_text"`
+
+ MatchLicense []configMatchLicense `ini:"match-license"`
+
+ MaxLineMatch int `ini:"default::max_line_match"`
+}
+
+func (cfg *config) init() (err error) {
+ const defMaxLineMatch = 10
+ if cfg.LicenseIdentifier == `` {
+ return errors.New(`empty default license_identifier`)
+ }
+ if cfg.FileCopyrightText == `` {
+ return errors.New(`empty default file_copyright_text`)
+ }
+ if cfg.MaxLineMatch <= 0 {
+ cfg.MaxLineMatch = defMaxLineMatch
+ }
+ return nil
+}