mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-20 02:31:50 +00:00
commands: Support config from ENV
So ```bash env HUGO_TITLE="Some Title" hugo server ``` Will change the `title`. Fixes #2090
This commit is contained in:
parent
0743c76795
commit
b7fd410245
1 changed files with 4 additions and 1 deletions
|
@ -17,7 +17,6 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/hugo/hugofs"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -27,6 +26,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/hugo/hugofs"
|
||||||
|
|
||||||
"github.com/spf13/hugo/parser"
|
"github.com/spf13/hugo/parser"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
|
|
||||||
|
@ -318,6 +319,8 @@ func loadDefaultSettings() {
|
||||||
// A Hugo command that calls initCoreCommonFlags() can pass itself
|
// A Hugo command that calls initCoreCommonFlags() can pass itself
|
||||||
// as an argument to have its command-line flags processed here.
|
// as an argument to have its command-line flags processed here.
|
||||||
func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
||||||
|
viper.AutomaticEnv()
|
||||||
|
viper.SetEnvPrefix("hugo")
|
||||||
viper.SetConfigFile(cfgFile)
|
viper.SetConfigFile(cfgFile)
|
||||||
// See https://github.com/spf13/viper/issues/73#issuecomment-126970794
|
// See https://github.com/spf13/viper/issues/73#issuecomment-126970794
|
||||||
if source == "" {
|
if source == "" {
|
||||||
|
|
Loading…
Reference in a new issue