Since the extended version is only available for amd64 I have started to build Hugo on our own in a multi stage Dockerfile. Now we are installing both binaries, regular hugo and extended hugo, bundled into the Docker image. Beside that the download for regular hugo and extended hugo should also be more solid now. After that I have also added more aliases for the environment variables. As mentioned on some GitHub issue we are also installing more required packages for a downloaded extended Hugo version as this relies on libc6-compat and libstdc++.
127 lines
2.8 KiB
Go
127 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var (
|
|
version = "unknown"
|
|
)
|
|
|
|
func main() {
|
|
app := cli.NewApp()
|
|
app.Name = "hugo plugin"
|
|
app.Usage = "hugo plugin"
|
|
app.Action = run
|
|
app.Version = version
|
|
app.Flags = []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "drafts",
|
|
Usage: " include content marked as draft",
|
|
EnvVar: "PLUGIN_BUILDDRAFTS,PLUGIN_DRAFTS",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "expired",
|
|
Usage: "include expired content",
|
|
EnvVar: "PLUGIN_BUILDEXPIRED,PLUGIN_EXPIRED",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "future",
|
|
Usage: "include content with publishdate in the future",
|
|
EnvVar: "PLUGIN_BUILDFUTURE,PLUGIN_FUTURE",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "cache",
|
|
Usage: "change cache directory (useful when using caching plugins)",
|
|
EnvVar: "PLUGIN_CACHEDIR,PLUGIN_CACHE",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "config",
|
|
Usage: "config file (default is path/config.yaml|json|toml)",
|
|
EnvVar: "PLUGIN_CONFIG",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "content",
|
|
Usage: "filesystem path to content directory",
|
|
EnvVar: "PLUGIN_CONTENT",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "layout",
|
|
Usage: "filesystem path to layout directory",
|
|
EnvVar: "PLUGIN_LAYOUT",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "output",
|
|
Usage: "filesystem path to write files to",
|
|
EnvVar: "PLUGIN_OUTPUT",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "source",
|
|
Usage: "filesystem path to read files relative from",
|
|
EnvVar: "PLUGIN_SOURCE",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "theme",
|
|
Usage: "theme to use (located in /themes/THEMENAME/)",
|
|
EnvVar: "PLUGIN_THEME",
|
|
Value: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "url",
|
|
Usage: "hostname (and path) to the root",
|
|
EnvVar: "PLUGIN_URL",
|
|
Value: "",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "validate",
|
|
Usage: "validate config file before generation",
|
|
EnvVar: "PLUGIN_VALIDATE",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "hugoversion",
|
|
Usage: "the hugo version to be used",
|
|
EnvVar: "PLUGIN_HUGO_VERSION,PLUGIN_VERSION",
|
|
Value: "",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "extended",
|
|
Usage: "If the hugo extended package should be used",
|
|
EnvVar: "PLUGIN_EXTENDED",
|
|
},
|
|
}
|
|
if err := app.Run(os.Args); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func run(c *cli.Context) error {
|
|
plugin := Plugin{
|
|
Config: Config{
|
|
URL: c.String("url"),
|
|
Drafts: c.Bool("drafts"),
|
|
Expired: c.Bool("expired"),
|
|
Future: c.Bool("future"),
|
|
Validate: c.Bool("validate"),
|
|
Config: c.String("config"),
|
|
Content: c.String("content"),
|
|
Layout: c.String("layout"),
|
|
Output: c.String("output"),
|
|
Source: c.String("source"),
|
|
Theme: c.String("theme"),
|
|
Version: c.String("hugoversion"),
|
|
Extended: c.Bool("extended"),
|
|
},
|
|
BuildInVersion: os.Getenv("PLUGIN_HUGO_SHIPPED_VERSION"),
|
|
}
|
|
|
|
return plugin.Exec()
|
|
}
|