Commit 6d022e5
Changed files (3)
docs/config.example.toml
@@ -19,10 +19,6 @@
# Defaults to "Git repositories" when omitted.
site_name = "Gitmal"
-# Optional owner name shown in some page titles.
-# owner = "My Organization"
-
-
# =============================================================================
# Multi-repo mode — [[repos]]
# =============================================================================
@@ -70,12 +66,39 @@ site_name = "Gitmal"
+# -------- Global settings (optional, overrideable by CLI flags) --------
+# These options can also be passed on the command line (higher priority).
+# When omitted, the CLI flag default (or program default) is used.
+
+# Code highlighting theme name (default "github").
+# theme = "github"
+#
+# Explicit light/dark theme overrides (takes precedence over --theme).
+# theme_light = "github"
+# theme_dark = "github-dark"
+#
+# Regex filter for branches to include (default: empty = all branches).
+# branches = "feature-.*"
+#
+# Output directory for generated HTML files (default "output").
+# output = "_site"
+#
+# Minify all generated HTML files.
+# minify = true
+#
+# Generate .gz files in addition to HTML.
+# gzip = true
+#
+# Generate static files for Git dumb HTTP protocol.
+# git = true
+#
+# Embed all CSS inline in HTML instead of external files.
+# inline_styles = true
+
# =============================================================================
-# Corresponding CLI flags
+# Corresponding CLI flags (higher priority than config)
# =============================================================================
-# Most flags can also be passed on the command line (higher priority):
-#
-# --branches=regex Branch filter regex (default: empty = all branches)
+# --branches=regex Branch filter regex
# --default-branch Default branch name (overrides config)
# --theme Code highlighting theme (default "github")
# --theme-light Light theme override
config.go
@@ -26,9 +26,18 @@ type RepoEntry struct {
}
type Config struct {
- SiteName string `toml:"site_name"`
- Repo *SingleRepoConfig `toml:"repo"`
- Repos []RepoEntry `toml:"repos"`
+ SiteName string `toml:"site_name"`
+ Repo *SingleRepoConfig `toml:"repo"`
+ Repos []RepoEntry `toml:"repos"`
+ Theme string `toml:"theme"`
+ ThemeLight string `toml:"theme_light"`
+ ThemeDark string `toml:"theme_dark"`
+ Branches string `toml:"branches"`
+ Output string `toml:"output"`
+ Minify bool `toml:"minify"`
+ Gzip bool `toml:"gzip"`
+ Git bool `toml:"git"`
+ InlineStyles bool `toml:"inline_styles"`
}
func parseConfig(path string) (*Config, error) {
main.go
@@ -14,7 +14,6 @@ import (
)
var (
- flagOwner string
flagName string
flagOutput string
flagBranches string
@@ -31,7 +30,6 @@ var (
)
type Params struct {
- Owner string
Name string
SiteName string
RepoDir string
@@ -69,7 +67,6 @@ func main() {
_, noFiles := os.LookupEnv("NO_FILES")
_, noCommitsList := os.LookupEnv("NO_COMMITS_LIST")
- flag.StringVar(&flagOwner, "owner", "", "Project owner")
flag.StringVar(&flagName, "name", "", "Project name")
flag.StringVar(&flagOutput, "output", "output", "Output directory for generated HTML files")
flag.StringVar(&flagBranches, "branches", "", "Regex for branches to include")
@@ -102,7 +99,6 @@ func main() {
}
baseParams := Params{
- Owner: flagOwner,
Style: flagTheme,
StyleLight: styleLight,
StyleDark: styleDark,
@@ -159,9 +155,57 @@ func main() {
generatables = append(generatables, repoGeneration{
RepoDir: repoPath,
Name: repoName,
+ Description: cfg.Repo.Description,
DefaultBranch: defaultBranch,
})
}
+
+ // === Merge global config values with CLI flags (CLI takes priority) ===
+ if !flag.CommandLine.Changed("theme") && cfg.Theme != "" {
+ flagTheme = cfg.Theme
+ baseParams.Style = flagTheme
+ baseParams.Dark = themeStyles[flagTheme] == "dark"
+ }
+ if !flag.CommandLine.Changed("theme-light") && cfg.ThemeLight != "" {
+ flagThemeLight = cfg.ThemeLight
+ }
+ if !flag.CommandLine.Changed("theme-dark") && cfg.ThemeDark != "" {
+ flagThemeDark = cfg.ThemeDark
+ }
+ if (!flag.CommandLine.Changed("theme") && cfg.Theme != "") ||
+ (!flag.CommandLine.Changed("theme-light") && cfg.ThemeLight != "") ||
+ (!flag.CommandLine.Changed("theme-dark") && cfg.ThemeDark != "") {
+ styleLight, styleDark, err = resolveTheme(flagTheme, flagThemeLight, flagThemeDark)
+ if err != nil {
+ panic(err)
+ }
+ baseParams.StyleLight = styleLight
+ baseParams.StyleDark = styleDark
+ }
+ if !flag.CommandLine.Changed("branches") && cfg.Branches != "" {
+ flagBranches = cfg.Branches
+ }
+ if !flag.CommandLine.Changed("output") && cfg.Output != "" {
+ flagOutput = cfg.Output
+ outputDir, err = filepath.Abs(flagOutput)
+ if err != nil {
+ panic(err)
+ }
+ baseParams.OutputDir = outputDir
+ }
+ if !flag.CommandLine.Changed("inline-styles") {
+ flagInlineStyles = cfg.InlineStyles
+ baseParams.InlineStyles = flagInlineStyles
+ }
+ if !flag.CommandLine.Changed("minify") {
+ flagMinify = cfg.Minify
+ }
+ if !flag.CommandLine.Changed("gzip") {
+ flagGzip = cfg.Gzip
+ }
+ if !flag.CommandLine.Changed("git") {
+ flagGit = cfg.Git
+ }
}
if len(generatables) == 0 {