progresses on #19
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mholt/caddy/config/setup"
|
||||
@@ -8,15 +9,15 @@ import (
|
||||
|
||||
// Config is the add-on configuration set on Caddyfile
|
||||
type Config struct {
|
||||
Styles string
|
||||
Flags []string
|
||||
Styles string
|
||||
Hugo bool
|
||||
Args []string
|
||||
Command string
|
||||
}
|
||||
|
||||
// ParseHugo parses the configuration file
|
||||
func ParseHugo(c *setup.Controller) (*Config, error) {
|
||||
conf := &Config{
|
||||
Styles: "",
|
||||
}
|
||||
// ParseCMS parses the configuration file
|
||||
func ParseCMS(c *setup.Controller) (*Config, error) {
|
||||
conf := &Config{Hugo: true}
|
||||
|
||||
for c.Next() {
|
||||
for c.NextBlock() {
|
||||
@@ -30,9 +31,23 @@ func ParseHugo(c *setup.Controller) (*Config, error) {
|
||||
conf.Styles = strings.TrimPrefix(conf.Styles, "/")
|
||||
// Add a beginning slash to make a
|
||||
conf.Styles = "/" + conf.Styles
|
||||
case "flags":
|
||||
conf.Flags = c.RemainingArgs()
|
||||
if len(conf.Flags) == 0 {
|
||||
case "hugo":
|
||||
if !c.NextArg() {
|
||||
return nil, c.ArgErr()
|
||||
}
|
||||
var err error
|
||||
conf.Hugo, err = strconv.ParseBool(c.Val())
|
||||
if err != nil {
|
||||
return conf, err
|
||||
}
|
||||
case "command":
|
||||
if !c.NextArg() {
|
||||
return nil, c.ArgErr()
|
||||
}
|
||||
conf.Command = c.Val()
|
||||
case "args":
|
||||
conf.Args = c.RemainingArgs()
|
||||
if len(conf.Args) == 0 {
|
||||
return conf, c.ArgErr()
|
||||
}
|
||||
}
|
||||
@@ -44,7 +59,7 @@ func ParseHugo(c *setup.Controller) (*Config, error) {
|
||||
}
|
||||
|
||||
func (c *Config) parseFlags() {
|
||||
for index, element := range c.Flags {
|
||||
c.Flags[index] = strings.Replace(element, "\"", "", -1)
|
||||
for index, element := range c.Args {
|
||||
c.Args[index] = strings.Replace(element, "\"", "", -1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user