Skip to content

Commit

Permalink
build man page with 'rack init'
Browse files Browse the repository at this point in the history
  • Loading branch information
jrperritt committed Jul 29, 2015
1 parent 81a919e commit 3192188
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ commands have been tested against Rackspace's live API.`
func Cmds() []cli.Command {
return []cli.Command{
{
Name: "init",
Usage: "[Linux/OS X only] Setup environment with command completion for the Bash shell.",
Action: setup.Init,
Name: "init",
Usage: "[Linux/OS X only] Creates the rack man page and sets up command completion for the Bash shell.",
Action: func(c *cli.Context) {
setup.Init(c)
man()
},
},
{
Name: "configure",
Expand Down
12 changes: 5 additions & 7 deletions script/man.go → man.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ import (
"strings"
"time"

r "github.com/jrperritt/rack"
"github.com/jrperritt/rack/commandoptions"
"github.com/jrperritt/rack/internal/github.com/codegangsta/cli"
"github.com/jrperritt/rack/util"
)

func main() {

func man() {
content := fmt.Sprintln(`.\" Manpage for rack`)
content += fmt.Sprintln(`.\" Contact [email protected] to correct errors or typos`)
content += fmt.Sprintf(`.TH man 1 "%s" "%s" "rack man page"`+"\n", time.Now().Format("06 May 2010"), util.Version)
content += fmt.Sprintln(`.SH NAME`)
content += fmt.Sprintf(`rack \- %s`+"\n", r.Usage())
content += fmt.Sprintf(`rack \- %s`+"\n", Usage())
content += fmt.Sprintln(`.SH SYNOPSIS`)
content += fmt.Sprintln("rack [GLOBALS] command subcommand [OPTIONS]")
content += fmt.Sprintln(`.SH DESCRIPTION`)
content += fmt.Sprintf("%s\n\n\n", r.Desc())
content += fmt.Sprintf("%s\n\n\n", Desc())

content += fmt.Sprintln("The following global options are available:")
for _, flag := range commandoptions.GlobalFlags() {
Expand All @@ -37,7 +35,7 @@ func main() {
}

content += fmt.Sprintln(`.SH TOP-LEVEL COMMANDS`)
for _, cmd := range r.Cmds() {
for _, cmd := range Cmds() {
if len(cmd.Subcommands) > 0 {
continue
}
Expand All @@ -46,7 +44,7 @@ func main() {
content += fmt.Sprintln(cmd.Usage)
}

for _, cmd := range r.Cmds() {
for _, cmd := range Cmds() {
if len(cmd.Subcommands) == 0 {
continue
}
Expand Down
7 changes: 0 additions & 7 deletions script/prep-travis-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,12 @@ mkdir -p $BUILDDIR/$BASEDIR
mkdir -p $BUILDDIR/$TREEDIR

BASENAME="rack"
MANFILE="rack.1"

# Base build not in build dir to prevent accidental upload on failure
RACKBUILD="${BASENAME}${SUFFIX}"

go build -o $RACKBUILD

# Generate man page
go run script/man.go
cp $MANFILE ${BUILDDIR}/${TREEDIR}/${BASENAME}-${BRANCH}".1"

# Ship /tree/rack-branchname
cp $RACKBUILD ${BUILDDIR}/${TREEDIR}/${BASENAME}-${BRANCH}${SUFFIX}
echo "Fresh build for branch '${BRANCH}' at "
Expand All @@ -106,11 +101,9 @@ echo "${CDN}/${TREEDIR}/${BASENAME}-${BRANCH}${SUFFIX}"
if [ "$BRANCH" == "master" ]; then
# Only when we're on master do we spit out the official ones.
cp $RACKBUILD ${BUILDDIR}/${BASEDIR}/${BASENAME}${SUFFIX}
cp $MANFILE ${BUILDDIR}/${BASEDIR}/${BASENAME}".1"
echo "Get it while it's hot at"
echo "${CDN}/${BASEDIR}/${BASENAME}${SUFFIX}"
fi

# Clean up after build
rm $RACKBUILD
rm $MANFILE

0 comments on commit 3192188

Please sign in to comment.