Skip to content

Commit

Permalink
refactor(help): display more useful information
Browse files Browse the repository at this point in the history
Updated all commands to have short usages and created a long form
description for the root stencil command.

Fixed an issue where `--version` information would be embedded in the
help page.
  • Loading branch information
jaredallard committed Jun 18, 2024
1 parent 87dcc63 commit f421192
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/stencil/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
func NewCreateCommand() *cli.Command {
return &cli.Command{
Name: "create",
Usage: "create a new stencil project or module",
Description: "Commands to create template repositories, or stencil powered repositories",
Subcommands: []*cli.Command{
NewCreateModuleCommand(),
Expand Down
1 change: 1 addition & 0 deletions cmd/stencil/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
func NewDescribeCommand() *cli.Command {
return &cli.Command{
Name: "describe",
Usage: "describe a file created by stencil",
Description: "Print information about a known file rendered by a template",
Action: func(c *cli.Context) error {
if c.NArg() != 1 {
Expand Down
15 changes: 11 additions & 4 deletions cmd/stencil/stencil.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,24 @@ import (
//
//nolint:gochecknoinits
func init() {
cli.VersionPrinter = func(c *cli.Context) {
fmt.Println(c.App.Version)
cli.VersionPrinter = func(_ *cli.Context) {
fmt.Println(version.Version.String())
}
}

var description = "" +
"Stencil is a smart templating engine that helps you create and manage templates\n" +
"for your projects. Using go templates, you can create pluggable modules with\n" +
"templates or, native extensions in any language.\n\n" +
"Checkout our documentation at https://stencil.rgst.io for more information."

// NewStencil returns a new CLI application for stencil.
func NewStencil(log slogext.Logger) *cli.App {
return &cli.App{
Version: version.Version.String(),
Version: version.Version.GitVersion,
Name: "stencil",
Description: "a smart templating engine for project development",
Usage: "a smart templating engine for project development",
Description: description,
Action: func(c *cli.Context) error {
log.Infof("stencil %s", c.App.Version)

Expand Down
1 change: 1 addition & 0 deletions cmd/stencil/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
func NewUpgradeCommand(log slogext.Logger) *cli.Command {
return &cli.Command{
Name: "upgrade",
Usage: "upgrade stencil modules",
Description: "Runs stencil with newer modules and updates stencil.lock to use them",
UsageText: "upgrade",
Action: func(c *cli.Context) error {
Expand Down

0 comments on commit f421192

Please sign in to comment.