gscp

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 19 Imported by: 0

README

gscp

The gscp command is meant to be analogous to the scp command: Just as scp can copy files to and from servers, the gscp command is meant to copy documents to and from Square 9 GlobalSearch.

Documentation

Index

Constants

View Source
const (
	// FieldNameListKey can be specified in Index Spec's Fields to
	// define the field sequence in the index file.  Field names
	// should be separated by FieldNameListSep.
	FieldNameListKey = "fieldlist"

	// FieldNameListSep is the separator between field names in
	// the field list
	FieldNameListSep = ","

	// ArchiveNameKey can be specified in Index Spec's Fields to
	// allow the columns' field names to be looked up from the
	// archive fields.
	ArchiveNameKey = "archive"
)

Variables

This section is empty.

Functions

func CopyFromSourceToDestSpec

func CopyFromSourceToDestSpec(ctx context.Context, source, dest *Spec, config *Config) (Err error)

func CreateWebClientMapContext

func CreateWebClientMapContext(ctx context.Context) context.Context

func Main

func Main(ctx context.Context, config MainConfig) error

Main is the main entry point for the program after the command line is parsed.

func OpenFilenameCreate

func OpenFilenameCreate(filename string, overwrite bool) (f *os.File, err error)

OpenFilenameCreate calls os.Create but first checks

func OpenFilenameRead

func OpenFilenameRead(filename string) (io.ReadCloser, error)

OpenFilenameRead calls os.Open but wraps the error with more context if opening fails.

func ReadIntoSpecFrom

func ReadIntoSpecFrom(ctx context.Context, r io.Reader, sp *Spec, config *Config) error

func WriteSpecTo

func WriteSpecTo(ctx context.Context, sp *Spec, w io.Writer) error

Types

type Config

type Config struct {
	// IndexOnly will not export documents when the destination is
	// an index file; it will only export the CSV.
	IndexOnly bool

	// AllowOverwrite allows the destination to be overwritten
	// if it already exists.
	AllowOverwrite bool

	// Unsecure will use HTTP instead of HTTPS.  Its purpose is
	// just for temporary development environments that don't have
	// SSL configured.  Do not use this for test or production
	// systems.
	Unsecure bool

	// WebSessionPoolLimit defines the number of sessions to limit
	// the pool to.
	WebSessionPoolLimit int
}

type MainConfig

type MainConfig struct {
	FromIndex bool
	Source    string
	ToIndex   bool
	Dest      string
	Config    Config
}

type Spec

type Spec struct {
	// Kind of the specification
	Kind SpecKind

	// Username is the GlobalSearch username
	Username string

	// Password for the GlobalSearch username
	Password string

	// Hostname that the GlobalSearch API server is running on
	Hostname string

	// APIPath is the GlobalSearch "square9api" API path.
	APIPath string

	// Database is the name of the GlobalSearch database.
	Database string

	// ArchivePath is a the name of the archive (or, in the case
	// of "subarchives," a slash-separated path to the subarchive).
	//
	// For Local Specs, ArchivePath holds the local path.
	ArchivePath string

	// Search is an optional search specification.  It is only
	// populated in source specifications.
	Search string

	// Fields holds a collection of GlobalSearch fields for
	// destination specifications or search prompts for source
	// specifications.
	Fields map[string]string
}

Spec is a specification for a gscp source or destination. Either of which could be a local file or a gscp "pseudo-URI."

func ParseSpec

func ParseSpec(specString string) (*Spec, error)

ParseSpec parses a gscp source or destination specification into a Spec structure.

func (*Spec) Copy

func (sp *Spec) Copy(changes ...func(*Spec)) *Spec

Copy copies the spec to a new spec and applies zero or more changes

func (*Spec) Eq

func (sp *Spec) Eq(b *Spec) bool

Eq checks if two Specs are equal.

func (*Spec) IsLocal

func (sp *Spec) IsLocal() bool

IsLocal returns true if the specification is a local file specification

func (*Spec) String

func (sp *Spec) String() string

func (*Spec) StringWithPassword

func (sp *Spec) StringWithPassword() string

type SpecKind

type SpecKind uint8

SpecKind defines the kind of item a Spec refers to.

const (
	// LocalSpec is set when the specification refers to a local
	// path.  When it is set, the Spec's ArchivePath holds the
	// local path.
	LocalSpec SpecKind = 1 << iota

	// IndexSpec is set when the specification refers to an index
	// of other specifications.
	IndexSpec

	// UnsecureSpec allows connecting to the non-local spec
	// with HTTP instead of HTTPS.
	UnsecureSpec
)

func (SpecKind) HasAll

func (k SpecKind) HasAll(flags SpecKind) bool

type WebSessionPoolLimit

type WebSessionPoolLimit struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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