Esempio n. 1
0
This command lets you to take a look at the book contents
and interactively navigate through the parts.`,

	Flags: []climax.Flag{
		{
			Name:  "show-imaginary",
			Short: "A",
			Help: `Show all parts, including ones present in your summary,
but actually missing.`,
		},
	},

	Handle: func(ctx climax.Context) int {
		workingPath, _ := os.Getwd()
		book, err := model.LocateBook(workingPath)
		if err != nil {
			ctx.Log("couldn't open the book:", err)
			return 1
		}

		book.Root.Caption = book.Name

		wd, _ := os.Getwd()

		fmt.Println(model.Tree(book.Root, func(given model.Part) string {
			label := given.Caption

			if given.Path == wd {
				label += "*"
			}
Esempio n. 2
0
File: new.go Progetto: tucnak/kamu
file inside would be created.`},
		{`-d "Prerequisites" --slug="stuff"`, `Instead of creating a "prerequisites" directory, Camus would create
a "stuff" directory (note, slugged string must meet some requirements).`},
	},

	Handle: func(ctx climax.Context) int {
		if len(ctx.Args) != 1 {
			ctx.Log("new accepts only one argument")
			return 1
		}

		caption := ctx.Args[0]

		wd, _ := os.Getwd()

		book, err := model.LocateBook(wd)
		if err != nil {
			ctx.Log("couldn't locate the book:", err)
			return 1
		}

		self, err := book.PartByPath(wd)
		if err != nil {
			ctx.Log("outside the book's content directory")
			return 1
		}

		var slug string
		if userDefined, ok := ctx.Get("slug"); ok {
			slug = userDefined
		} else {