add examples to pkg

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
diff --git a/cli/example_action_test.go b/cli/example_action_test.go
new file mode 100644
index 0000000..5cd38ae
--- /dev/null
+++ b/cli/example_action_test.go
@@ -0,0 +1,62 @@
+package cli_test
+
+import (
+	"context"
+	"flag"
+	"fmt"
+	"log"
+	"os"
+	"os/signal"
+	"syscall"
+
+	"github.com/genuinetools/pkg/cli"
+)
+
+func ExampleNewProgram_withSingleAction() {
+	// Create a new cli program.
+	p := cli.NewProgram()
+	p.Name = "yo"
+	p.Description = `A tool that prints "yo"`
+
+	// Set the GitCommit and Version.
+	p.GitCommit = "ef2f64f"
+	p.Version = "v0.1.0"
+
+	// Setup the global flags.
+	var (
+		debug bool
+	)
+	p.FlagSet = flag.NewFlagSet("global", flag.ExitOnError)
+	p.FlagSet.BoolVar(&debug, "d", false, "enable debug logging")
+
+	// Set the before function.
+	p.Before = func(ctx context.Context) error {
+		// Set the log level.
+		if debug {
+			// Setup your logger here...
+		}
+
+		return nil
+	}
+
+	// Set the main program action.
+	p.Action = func(ctx context.Context, args []string) error {
+		// On ^C, or SIGTERM handle exit.
+		c := make(chan os.Signal, 1)
+		signal.Notify(c, os.Interrupt)
+		signal.Notify(c, syscall.SIGTERM)
+		go func() {
+			for sig := range c {
+				log.Printf("Received %s, exiting.", sig.String())
+				os.Exit(0)
+			}
+		}()
+
+		fmt.Fprintln(os.Stdout, "yo")
+		return nil
+	}
+
+	// Run our program.
+	p.Run()
+
+}
diff --git a/cli/example_command_test.go b/cli/example_command_test.go
new file mode 100644
index 0000000..0545bf9
--- /dev/null
+++ b/cli/example_command_test.go
@@ -0,0 +1,64 @@
+package cli_test
+
+import (
+	"context"
+	"flag"
+	"fmt"
+	"os"
+
+	"github.com/genuinetools/pkg/cli"
+)
+
+const yoHelp = `Send "yo" to the program.`
+
+func (cmd *yoCommand) Name() string      { return "yo" }
+func (cmd *yoCommand) Args() string      { return "" }
+func (cmd *yoCommand) ShortHelp() string { return yoHelp }
+func (cmd *yoCommand) LongHelp() string  { return yoHelp }
+func (cmd *yoCommand) Hidden() bool      { return false }
+
+func (cmd *yoCommand) Register(fs *flag.FlagSet) {}
+
+type yoCommand struct{}
+
+func (cmd *yoCommand) Run(ctx context.Context, args []string) error {
+	fmt.Fprintln(os.Stdout, "yo")
+	return nil
+}
+
+func ExampleNewProgram_withCommand() {
+	// Create a new cli program.
+	p := cli.NewProgram()
+	p.Name = "yo"
+	p.Description = `A tool that prints "yo" when you run the command "yo"`
+
+	// Set the GitCommit and Version.
+	p.GitCommit = "ef2f64f"
+	p.Version = "v0.1.0"
+
+	// Setup the global flags.
+	var (
+		debug bool
+	)
+	p.FlagSet = flag.NewFlagSet("global", flag.ExitOnError)
+	p.FlagSet.BoolVar(&debug, "d", false, "enable debug logging")
+
+	// Set the before function.
+	p.Before = func(ctx context.Context) error {
+		// Set the log level.
+		if debug {
+			// Setup your logger here...
+		}
+
+		return nil
+	}
+
+	// Add our commands.
+	p.Commands = []cli.Command{
+		&yoCommand{},
+	}
+
+	// Run our program.
+	p.Run()
+
+}