main
Raw Download raw file
 1package cli
 2
 3import (
 4	"errors"
 5	"fmt"
 6	"os"
 7)
 8
 9// ErrUsage indicates incorrect command-line usage.
10var ErrUsage = errors.New("usage error")
11
12const usage = `usage: forge <command> [arguments]
13
14commands:
15  static    generate static site from bare git repos
16`
17
18// Run dispatches to the appropriate subcommand based on args.
19func Run(args []string) error {
20	if len(args) == 0 {
21		fmt.Fprint(os.Stderr, usage)
22		return ErrUsage
23	}
24
25	switch args[0] {
26	case "static":
27		return runStatic(args[1:])
28	default:
29		fmt.Fprint(os.Stderr, usage)
30		return fmt.Errorf("unknown command %q: %w", args[0], ErrUsage)
31	}
32}