cmd

package
v0.0.0-...-aa602b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdBuild = &cli.Command{
	Name:      "build",
	Usage:     "Builds a book from its markdown files",
	ArgsUsage: "[dir]",
	Action: func(ctx *cli.Context) error {
		dir := ctx.Args().First()
		if dir == "" {
			dir, _ = os.Getwd()
		}
		if err := BuildBook(dir); err != nil {
			fmt.Println("build book failed:", err)
			os.Exit(1)
		}
		return nil
	},
}
View Source
var CmdClean = &cli.Command{
	Name:      "clean",
	Usage:     "Deletes a built book",
	ArgsUsage: "[dir]",
	Action: func(ctx *cli.Context) error {
		dir := ctx.Args().First()
		if dir == "" {
			dir, _ = os.Getwd()
		}
		if err := CleanBook(dir); err != nil {
			fmt.Println("delete book failed:", err)
			os.Exit(1)
		}
		return nil
	},
}
View Source
var CmdInit = &cli.Command{
	Name:      "init",
	Usage:     "Creates a new book",
	ArgsUsage: "[dir]",
	Action: func(ctx *cli.Context) error {
		dir := ctx.Args().First()
		if dir == "" {
			dir, _ = os.Getwd()
		}
		if err := InitBook(dir); err != nil {
			fmt.Println("init book failed:", err)
			os.Exit(1)
		}
		return nil
	},
}
View Source
var CmdServe = &cli.Command{
	Name:      "serve",
	Usage:     "Serves a book at http://localhost:3000",
	ArgsUsage: "[dir]",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "http",
			Usage: "HTTP service address",
			Value: "localhost:3000",
		},
	},
	Action: func(ctx *cli.Context) error {
		dir := ctx.Args().First()
		if dir == "" {
			dir, _ = os.Getwd()
		}

		Serve(dir, ctx.String("http"))
		return nil
	},
}

Functions

func BuildBook

func BuildBook(path string) error

func CleanBook

func CleanBook(path string) error

func InitBook

func InitBook(name string) error

func Main

func Main()

func Serve

func Serve(path, addr string)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL