help

package module
v0.0.0-...-a16480b Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2015 License: Apache-2.0 Imports: 6 Imported by: 2

README

Build Status GoDoc

Help

Package help allows you to define help sections for your command line interfaces. It extends the flag package to provide flag support for help section.

The package defines a subcommand "help" that you can integrate into you main CLI.

$ sbr help file

The subcommand displays a summary of all the sections available, or the detail for any section.

sections summary

$ sbr help
Usage: sbr help  <section>

where <section> is one of:
   1.file             help relative to file management

Sections are written in Markdown, and displayed in the terminal output using ansi escape code.

registering sections

help.Section("file", "help relative to file management", `
# File Format

this is Mardown *format*

`)

this is enough to register the section "file", into the global var help.Command

integration with http://github.com/rakyll/command

the package github.com/ericaro/help contains a var Command that implements Rakyll's Cmd interface

Cmd interface {
    Flags(*flag.FlagSet) *flag.FlagSet
    Run(args []string)
}

So you can just register the help subcommand:

command.On("help","display help", help.Command, nil)

License

help is available under the Apache License, Version 2.0.

Branches

master: Build Status against go versions:

  • 1.2
  • 1.3
  • tip

dev: Build Status against go versions:

  • 1.2
  • 1.3
  • tip

Documentation

Overview

Package help allows you to define help sections for your command line interfaces. It extends the flag package to provide flag support for help section.

The package defines a subcommand "help" that you can integrate into you main CLI.

For example:

$ sbr help file

The subcommand displays a summary of all the sections available or the detail for any section.

Sections summary example:

$ sbr help
Usage: sbr help  <section>

where <section> is one of:
   1.file             help relative to file management

Sections details:

$ sbr help file dir
File

This document describe the file format
...

Sections are written using Markdown, and displayed in the terminal output using ansi escape code.

Index

Constants

This section is empty.

Variables

View Source
var (
	Command = New()
)

Functions

func Section

func Section(name, description, content string)

Section create a new section in 'Command'.

a section's name is used to identify it

a section's description is used in the summary

a section's content is a Markdown description.

Types

type HelpCommand

type HelpCommand struct {
	// contains filtered or unexported fields
}

HelpCommand contains a slice of sections representing the help subsystem.

HelpCommand can parse "args"

and it is compatible with rakyll command package.

func New

func New() *HelpCommand

New creates a new empty HelpCommand

func (*HelpCommand) Compgen

func (h *HelpCommand) Compgen(args []string, inword bool) (comp []string, err error)

Compgen returns a list of completion arguments (part of the compgen protocol)

func (*HelpCommand) Compgens

func (h *HelpCommand) Compgens(term *compgen.Terminator)

Compgens configures a Terminator to use the command itself for completion

func (*HelpCommand) Run

func (h *HelpCommand) Run(args []string)

Run execute the HelpCommand:

with no args: prints the section summary

with arguments print out every section found in the args, or an error message

func (*HelpCommand) Section

func (h *HelpCommand) Section(name, description, content string)

Section create a new section in 'Command'.

a section's name is used to identify it

a section's description is used in the summary

a section's content is a Markdown description.

Jump to

Keyboard shortcuts

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