0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Merge pull request #676 from abiosoft/list-directives

Add flag to list directives.
This commit is contained in:
Matt Holt 2016-03-13 14:49:10 -06:00
commit fc10951dde
2 changed files with 22 additions and 5 deletions

View file

@ -69,6 +69,15 @@ var directiveOrder = []directive{
{"browse", setup.Browse},
}
// Directives returns the list of directives in order of priority.
func Directives() []string {
directives := make([]string, len(directiveOrder))
for i, d := range directiveOrder {
directives[i] = d.name
}
return directives
}
// RegisterDirective adds the given directive to caddy's list of directives.
// Pass the name of a directive you want it to be placed after,
// otherwise it will be placed at the bottom of the stack.

18
main.go
View file

@ -36,6 +36,7 @@ func init() {
flag.StringVar(&revoke, "revoke", "", "Hostname for which to revoke the certificate")
flag.StringVar(&caddy.Root, "root", caddy.DefaultRoot, "Root path to default site")
flag.BoolVar(&version, "version", false, "Show version")
flag.BoolVar(&directives, "directives", false, "List supported directives")
}
func main() {
@ -77,6 +78,12 @@ func main() {
}
os.Exit(0)
}
if directives {
for _, d := range caddy.Directives() {
fmt.Println(d)
}
os.Exit(0)
}
// Set CPU cap
err := setCPU(cpu)
@ -212,11 +219,12 @@ const appName = "Caddy"
// Flags that control program flow or startup
var (
conf string
cpu string
logfile string
revoke string
version bool
conf string
cpu string
logfile string
revoke string
version bool
directives bool
)
// Build information obtained with the help of -ldflags