cmd

package
v0.0.0-...-3fff119 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2015 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package cmd provides access to build on the walker CLI

This package makes it easy to create custom walker binaries that use their own Handler, Datastore, or Dispatcher. A crawler that uses the default for each of these requires simply:

func main() {
	cmd.Execute()
}

To create your own binary that uses walker's flags but has its own handler:

func main() {
	cmd.Handler(NewMyHandler())
	cmd.Execute()
}

Likewise if you want to set your own Datastore and Dispatcher:

func main() {
	cmd.DataStore(NewMyDatastore())
	cmd.Dispatcher(NewMyDatastore())
	cmd.Execute()
}

cmd.Execute() blocks until the program has completed (usually by being shutdown gracefully via SIGINT).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Datastore

func Datastore(d walker.Datastore)

Datastore sets the global datastore for this process

func Dispatcher

func Dispatcher(d walker.Dispatcher)

Dispatcher sets the global dispatcher for this process

func Execute

func Execute()

Execute will run the command specified by the command line

func Handler

func Handler(h walker.Handler)

Handler sets the global handler for this process

func ReadLinkClearOptions

func ReadLinkClearOptions()

ReadLinkClearOptions allows tests to clear readLink options

Types

type CommanderStreams

type CommanderStreams struct {
	Printf func(format string, args ...interface{})
	Errorf func(format string, args ...interface{})
	Exit   func(status int)
}

CommanderStreams holds the i/o functions that the test harness can spoof. This is useful since (a) the test harness modifies the normal stdout/stderr streams, and this can cause strange behavior

with tests if we then try to modify stdout/stderr to capture.

(b) there is no good way to spoof os.Exit, short of doing what we're doing by putting a layer of indirection

into the strack trace.

func Streams

func Streams(cstream CommanderStreams) CommanderStreams

Streams allows user to set global CommandStreams object

Jump to

Keyboard shortcuts

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