commands

package
v0.0.0-...-5b64428 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ListExtractorsCommand = "list extractors"
View Source
const ListModulesCommandString = "list modules"

Variables

View Source
var DefaultHttpClient = &http.Client{Timeout: time.Minute * 2}

Functions

func ConfigureClassifyCommand

func ConfigureClassifyCommand(ctx context.Context,
	app *kingpin.Application,
	globalFlags *config.GlobalFlags)

func ConfigureCreateClassifierCmd

func ConfigureCreateClassifierCmd(ctx context.Context, createCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

func ConfigureCreateDocumentCmd

func ConfigureCreateDocumentCmd(ctx context.Context, createCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

func ConfigureCreateExtractorCmd

func ConfigureCreateExtractorCmd(ctx context.Context, createCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

ConfigureCreateExtractorCmd configures kingpin with the 'create extractor' commands.

func ConfigureCreateExtractorTemplateCmd

func ConfigureCreateExtractorTemplateCmd(ctx context.Context, createCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

ConfigureCreateExtractorTemplateCmd configures kingpin with the 'create extractor-template' command.

func ConfigureCreateReadProfileCmd

func ConfigureCreateReadProfileCmd(ctx context.Context, createCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

func ConfigureDeleteClassifierCmd

func ConfigureDeleteClassifierCmd(ctx context.Context, deleteCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

func ConfigureDeleteDocumentCmd

func ConfigureDeleteDocumentCmd(ctx context.Context, deleteCmd *kingpin.CmdClause, flags *config.
	GlobalFlags)

ConfigureDeleteDocumentCmd configures kingpin with the 'delete document' command.

func ConfigureDeleteExtractorCmd

func ConfigureDeleteExtractorCmd(ctx context.Context, deleteCmd *kingpin.CmdClause, flags *config.
	GlobalFlags)

ConfigureDeleteExtractorCmd configures kingpin with the 'delete extractor' command.

func ConfigureDeleteReadProfileCmd

func ConfigureDeleteReadProfileCmd(ctx context.Context, deleteCmd *kingpin.CmdClause,
	flags *config.GlobalFlags)

func ConfigureExtractCommand

func ConfigureExtractCommand(ctx context.Context,
	app *kingpin.Application,
	globalFlags *config.GlobalFlags)

func ConfigureListClassifiersCmd

func ConfigureListClassifiersCmd(ctx context.Context, parentCmd *kingpin.CmdClause, flags *config.GlobalFlags)

Configures kingpin with the 'list classifiers' command

func ConfigureListDocumentsCmd

func ConfigureListDocumentsCmd(ctx context.Context, parentCmd *kingpin.CmdClause, flags *config.GlobalFlags)

Configures kingpin with the 'list documents' command

func ConfigureListExtractorsCmd

func ConfigureListExtractorsCmd(ctx context.Context, listCmd *kingpin.CmdClause, flags *config.GlobalFlags)

ConfigureListExtractorsCmd configures kingpin with the 'list extractors' command.

func ConfigureListModulesCommand

func ConfigureListModulesCommand(ctx context.Context,
	listCmd *kingpin.CmdClause, globalFlags *config.GlobalFlags)

func ConfigureListReadProfilesCmd

func ConfigureListReadProfilesCmd(ctx context.Context, parentCmd *kingpin.CmdClause, flags *config.GlobalFlags)

Configures kingpin with the 'list read-profiles' command

func ConfigureLoginCommand

func ConfigureLoginCommand(ctx context.Context,
	app *kingpin.Application,
	globalFlags *config.GlobalFlags)

ConfigureLoginCommand configures kingpin to add the login command.

func ConfigureReadCommand

func ConfigureReadCommand(ctx context.Context,
	app *kingpin.Application,
	globalFlags *config.GlobalFlags)

ConfigureReadCommand configures kingpin to call ExecuteRead after having successfully parsed the cli options.

func ConfigureRedactWithExtractionCommand

func ConfigureRedactWithExtractionCommand(ctx context.Context,
	app *kingpin.Application,
	globalFlags *config.GlobalFlags)

func ConfigureUploadClassifierCommand

func ConfigureUploadClassifierCommand(ctx context.Context,
	uploadCmd *kingpin.CmdClause,
	globalFlags *config.GlobalFlags)

func ConfigureUploadExtractorCommand

func ConfigureUploadExtractorCommand(ctx context.Context,
	uploadCommand *kingpin.CmdClause,
	globalFlags *config.GlobalFlags)

func ExecuteWithMessage

func ExecuteWithMessage(message string, fn func() error) error

Execute prints the provided message to stderr, runs fn(), then prints [OK] or [FAILED] depending on fn's success.

func Glob

func Glob(filePattern string) ([]string, error)

Glob searches provided the provided file pattern for files.

func GlobMany

func GlobMany(filePatterns []string) ([]string, error)

GlobMany searches multiple patterns for files.

func NewTable

func NewTable(writer io.Writer, headers []string) *tablewriter.Table

NewTable is a convenience method for creating tables used in a few places within the package.

Types

type ClassificationService

type ClassificationService interface {
	ClassifyAll(ctx context.Context, files []string, classifierName string, args client.ReadProfileArgs) error
}

type ClassifierCreator

type ClassifierCreator interface {
	Create(ctx context.Context, name string) error
}

type ClassifierDeleter

type ClassifierDeleter interface {
	Delete(ctx context.Context, name string) error
}

type ClassifierDeleterGetter

type ClassifierDeleterGetter interface {
	ClassifierDeleter
	ClassifierGetter
}

type ClassifierGetter

type ClassifierGetter interface {
	GetAll(ctx context.Context) (client.ClassifierList, error)
}

type ClassifierTrainer

type ClassifierTrainer interface {
	Train(ctx context.Context, name string, samplesArchive io.Reader) error
}

type ClassifierUploader

type ClassifierUploader interface {
	Upload(ctx context.Context, name string, contents io.Reader) error
}

type ClassifyCmd

type ClassifyCmd struct {
	ClassificationService ClassificationService
	FilePaths             []string
	ClassifierName        string
	ReadProfileArgs       client.ReadProfileArgs
}

func (*ClassifyCmd) Execute

func (cmd *ClassifyCmd) Execute(ctx context.Context) error

ExecuteClassify is the main entry point for the 'classify' command.

type ConsoleSecretReader

type ConsoleSecretReader struct {
}

func (ConsoleSecretReader) ReadLine

func (r ConsoleSecretReader) ReadLine(ctx context.Context) (string, error)

func (ConsoleSecretReader) ReadSecret

func (r ConsoleSecretReader) ReadSecret(ctx context.Context) (string, error)

type CreateClassifierCmd

type CreateClassifierCmd struct {
	Creator        ClassifierCreator
	Deleter        ClassifierDeleter
	Trainer        ClassifierTrainer
	ClassifierName string
	SamplesArchive *os.File
}

func (*CreateClassifierCmd) Execute

func (cmd *CreateClassifierCmd) Execute(ctx context.Context) error

type CreateDocumentCmd

type CreateDocumentCmd struct {
	Creator       client.DocumentCreator
	DocumentPaths []string
}

func (*CreateDocumentCmd) Execute

func (cmd *CreateDocumentCmd) Execute(ctx context.Context) error

type CreateExtractorCmd

type CreateExtractorCmd struct {
	Creator       ExtractorCreator
	ExtractorName string
	Template      *client.ExtractorTemplate
}

func (*CreateExtractorCmd) Execute

func (cmd *CreateExtractorCmd) Execute(ctx context.Context) error

Execute runs the 'create extractor' command.

type CreateExtractorTemplateCmd

type CreateExtractorTemplateCmd struct {
	Client    ModuleGetter
	ModuleIds []string
	Output    io.Writer
}

CreateExtractorTemplate is a command which accepts a list of module ids, retrieves their descriptions from aluma and generates a template json from them.

func (CreateExtractorTemplateCmd) Execute

Execute runs the command.

type CreateReadProfileCmd

type CreateReadProfileCmd struct {
	Creator   client.ReadProfileCreator
	Name      string
	Languages []string
}

func (*CreateReadProfileCmd) Execute

func (cmd *CreateReadProfileCmd) Execute(ctx context.Context) error

type CredentialsResolver

type CredentialsResolver struct{}

func (*CredentialsResolver) Resolve

func (r *CredentialsResolver) Resolve(clientId string, clientSecret string, configurationReader config.ConfigurationReader) (string, string, error)

type DeleteClassifierCmd

type DeleteClassifierCmd struct {
	Client         ClassifierDeleterGetter
	ClassifierName string
}

func (*DeleteClassifierCmd) Execute

func (cmd *DeleteClassifierCmd) Execute(ctx context.Context) error

Execute runs the 'delete classifier' command.

type DeleteDocumentCmd

type DeleteDocumentCmd struct {
	Client      DocumentDeleterGetter
	DocumentIDs []string
	DeleteAll   bool
}

func (*DeleteDocumentCmd) Execute

func (cmd *DeleteDocumentCmd) Execute(ctx context.Context) error

Execute is the entry point of the 'delete documents' command.

type DeleteExtractorCmd

type DeleteExtractorCmd struct {
	Client        ExtractorDeleterGetter
	ExtractorName string
}

func (*DeleteExtractorCmd) Execute

func (cmd *DeleteExtractorCmd) Execute(ctx context.Context) error

type DeleteReadProfileCmd

type DeleteReadProfileCmd struct {
	Client          client.ReadProfileGetterDeleter
	ReadProfileName string
}

func (*DeleteReadProfileCmd) Execute

func (cmd *DeleteReadProfileCmd) Execute(ctx context.Context) error

Execute runs the 'delete ReadProfile' command.

type DocumentDeleterGetter

type DocumentDeleterGetter interface {
	client.DocumentDeleter
	client.DocumentGetter
}

type ExtractCmd

type ExtractCmd struct {
	ExtractorName     string
	FilePaths         []string
	ReadProfileArgs   client.ReadProfileArgs
	ExtractionService ExtractionService
}

func (*ExtractCmd) Execute

func (cmd *ExtractCmd) Execute(ctx context.Context) error

ExecuteExtract is the main entry point for the 'extract' command.

type ExtractionService

type ExtractionService interface {
	ExtractAll(ctx context.Context, files []string,
		extractorName string, args client.ReadProfileArgs) error
}

type ExtractorCreator

type ExtractorCreator interface {
	Create(ctx context.Context, name string, config io.Reader) error
	CreateFromJson(ctx context.Context, name string, jsonTemplate io.Reader) error
	CreateFromModules(ctx context.Context, name string, modules client.ExtractorTemplate) error
}

type ExtractorDeleter

type ExtractorDeleter interface {
	Delete(ctx context.Context, name string) error
}

type ExtractorDeleterGetter

type ExtractorDeleterGetter interface {
	ExtractorDeleter
	ExtractorGetter
}

type ExtractorGetter

type ExtractorGetter interface {
	GetAll(ctx context.Context) (client.ExtractorList, error)
}

type ListClassifiersCmd

type ListClassifiersCmd struct {
	Client ClassifierGetter
}

func (*ListClassifiersCmd) Execute

func (cmd *ListClassifiersCmd) Execute(ctx context.Context) error

Executes the command.

type ListDocumentsCmd

type ListDocumentsCmd struct {
	Client client.DocumentGetter
}

func (*ListDocumentsCmd) Execute

func (cmd *ListDocumentsCmd) Execute(ctx context.Context) error

Executes the command.

type ListExtractorsCmd

type ListExtractorsCmd struct {
	Client ExtractorGetter
}

func (*ListExtractorsCmd) Execute

func (cmd *ListExtractorsCmd) Execute(ctx context.Context) error

Execute runs the 'list extractors' command.

func (ListExtractorsCmd) Usage

func (cmd ListExtractorsCmd) Usage() string

type ListModulesCmd

type ListModulesCmd struct {
	Client ModuleGetter
}

func (*ListModulesCmd) Execute

func (cmd *ListModulesCmd) Execute(ctx context.Context) error

func (ListModulesCmd) Usage

func (cmd ListModulesCmd) Usage() string

type ListReadProfilesCmd

type ListReadProfilesCmd struct {
	Client client.ReadProfileGetter
}

func (*ListReadProfilesCmd) Execute

func (cmd *ListReadProfilesCmd) Execute(ctx context.Context) error

Executes the command.

type LoginCmd

type LoginCmd struct {
	TokenRetriever      auth.TokenRetriever
	ConfigurationWriter config.ConfigurationWriter
}

func (*LoginCmd) Execute

func (cmd *LoginCmd) Execute(ctx context.Context, flags *config.GlobalFlags) error

type ModuleGetter

type ModuleGetter interface {
	GetAll(ctx context.Context) (client.ModuleList, error)
}

type ReadArgs

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

type ReadCmd

type ReadCmd struct {
	FilePaths       []string
	ReaderService   ReaderService
	ReadMode        client.ReadMode
	ReadProfileArgs client.ReadProfileArgs
}

ReadCmd represents the 'read' command. It relies on a 'ReaderService' to perform the actual OCR.

func (*ReadCmd) Execute

func (cmd *ReadCmd) Execute(ctx context.Context) error

Execute is the main entry point for the 'read' command.

type ReaderService

type ReaderService interface {
	ReadAll(ctx context.Context, files []string, readMode client.ReadMode, args client.ReadProfileArgs) error
}

type RedactWithExtractorCmd

type RedactWithExtractorCmd struct {
	ExtractorName    string
	FilePaths        []string
	ReadProfileArgs  client.ReadProfileArgs
	RedactionService RedactWithExtractorService
}

func (*RedactWithExtractorCmd) Execute

func (cmd *RedactWithExtractorCmd) Execute(ctx context.Context) error

ExecuteRedact is the main entry point for the 'redact' command.

type RedactWithExtractorService

type RedactWithExtractorService interface {
	RedactAllWithExtractor(ctx context.Context, files []string, extractorName string, args client.ReadProfileArgs) error
}

type UploadClassifierCmd

type UploadClassifierCmd struct {
	Uploader           ClassifierUploader
	ClassifierName     string
	ClassifierContents io.Reader
}

func (*UploadClassifierCmd) Execute

func (cmd *UploadClassifierCmd) Execute(ctx context.Context) error

Execute runs the command.

type UploadExtractorCmd

type UploadExtractorCmd struct {
	ExtractorCreator ExtractorCreator
	ExtractorName    string
	ExtractorContent io.Reader
}

func (*UploadExtractorCmd) Execute

func (cmd *UploadExtractorCmd) Execute(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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