rsyncopts

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package rsyncopts implements a parser for command-line options that implements a subset of popt(3) semantics; just enough to parse typical rsync(1) invocations without the advanced popt features like aliases or option prefix matching (not --del, only --delete).

If we encounter arguments that rsync(1) parses differently compared to this package, then this package should be adjusted to match rsync(1).

Index

Constants

View Source
const (
	POPT_ARG_NONE          = iota // int; No argument expected
	POPT_ARG_STRING               // char*; No type checking to be performed
	POPT_ARG_INT                  // int; An integer argument is expected
	POPT_ARG_LONG                 // long; A long integer is expected
	POPT_ARG_INCLUDE_TABLE        // nest another option table
	POPT_ARG_CALLBACK             // call a function
	POPT_ARG_INTL_DOMAIN          // <not documented in popt(3)>
	POPT_ARG_VAL                  // int; Integer value taken from val
	POPT_ARG_FLOAT                // float; A float argument is expected
	POPT_ARG_DOUBLE               // double; A double argument is expected
	POPT_ARG_LONGLONG             // long long; A long long integer is expected
	POPT_ARG_MAINCALL      = 16 + 11
	POPT_ARG_ARGV          = 12
	POPT_ARG_SHORT         = 13
	POPT_ARG_BITSET        = 16 + 14
)

see popt(3)

View Source
const (
	POPT_ERROR_NOARG        = -10 // missing argument
	POPT_ERROR_BADOPT       = -11 // unknown option
	POPT_ERROR_UNWANTEDARG  = -12 // option does not take an argument
	POPT_ERROR_OPTSTOODEEP  = -13 // aliases nested too deeply
	POPT_ERROR_BADQUOTE     = -15 // error in parameter quoting
	POPT_ERROR_ERRNO        = -16 // errno set, use strerror(errno)
	POPT_ERROR_BADNUMBER    = -17 // invalid numeric value
	POPT_ERROR_OVERFLOW     = -18 // number too large or too small
	POPT_ERROR_BADOPERATION = -19 // mutually exclusive logical operations requested
	POPT_ERROR_NULLARG      = -20 // opt->arg should not be NULL
	POPT_ERROR_MALLOC       = -21 // memory allocation failed
	POPT_ERROR_BADCONFIG    = -22 // config file failed sanity test
)

TODO(later): turn these into sentinel error values which stringify like poptStrerror()

View Source
const (
	OPT_SERVER = 1000 + iota
	OPT_DAEMON
	OPT_SENDER
	OPT_EXCLUDE
	OPT_EXCLUDE_FROM
	OPT_FILTER
	OPT_COMPARE_DEST
	OPT_COPY_DEST
	OPT_LINK_DEST
	OPT_HELP
	OPT_INCLUDE
	OPT_INCLUDE_FROM
	OPT_MODIFY_WINDOW
	OPT_MIN_SIZE
	OPT_CHMOD
	OPT_READ_BATCH
	OPT_WRITE_BATCH
	OPT_ONLY_WRITE_BATCH
	OPT_MAX_SIZE
	OPT_NO_D
	OPT_APPEND
	OPT_NO_ICONV
	OPT_INFO
	OPT_DEBUG
	OPT_BLOCK_SIZE
	OPT_USERMAP
	OPT_GROUPMAP
	OPT_CHOWN
	OPT_BWLIMIT
	OPT_STDERR
	OPT_OLD_COMPRESS
	OPT_NEW_COMPRESS
	OPT_NO_COMPRESS
	OPT_OLD_ARGS
	OPT_STOP_AFTER
	OPT_STOP_AT
	OPT_REFUSED_BASE = 9000
)
View Source
const (
	INFO_BACKUP infoLevel = iota
	INFO_COPY
	INFO_DEL
	INFO_FLIST
	INFO_MISC
	INFO_MOUNT
	INFO_NAME
	INFO_NONREG
	INFO_PROGRESS
	INFO_REMOVE
	INFO_SKIP
	INFO_STATS
	INFO_SYMSAFE
	COUNT_INFO
)
View Source
const (
	DEFAULT_PRIORITY priority = iota
	HELP_PRIORITY
	USER_PRIORITY
	LIMIT_PRIORITY
)
View Source
const (
	W_CLI = 1 << iota
	W_SRV
	W_SND
	W_REC
)
View Source
const (
	POPT_ARGFLAG_OR = 0x08000000
)
View Source
const POPT_ARG_MASK = 0x000000FF
View Source
const (
	POPT_BIT_SET = POPT_ARG_VAL | POPT_ARGFLAG_OR
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {

	// output
	Options       *Options
	RemainingArgs []string
	// contains filtered or unexported fields
}

func ParseArguments

func ParseArguments(args []string, gokrazyTable bool) (*Context, error)

rsync/options.c:parse_arguments

type GokrazyOptions

type GokrazyOptions struct {
	Config           string
	Listen           string
	MonitoringListen string
	AnonSSHListen    string
	ModuleMap        string
}

GokrazyOptions contains additional command-line flags, prefixed with gokr. (like --gokr.modulemap) to not clash with rsync flag names.

type Options

type Options struct {
	Gokrazy GokrazyOptions
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions() *Options

NewOptions returns an Options struct with all options initialized to their default values. Note that ParseArguments will set some options (that default to -1) based on the encountered command-line flags and built-in rules.

func (*Options) AlwaysChecksum

func (o *Options) AlwaysChecksum() bool

func (*Options) ConnectTimeoutSeconds

func (o *Options) ConnectTimeoutSeconds() int

func (*Options) Daemon

func (o *Options) Daemon() bool

func (*Options) DeleteMode

func (o *Options) DeleteMode() bool

func (*Options) DryRun

func (o *Options) DryRun() bool

func (*Options) Help

func (o *Options) Help() string

func (*Options) LocalServer

func (o *Options) LocalServer() bool

func (*Options) PreserveDevices

func (o *Options) PreserveDevices() bool

func (*Options) PreserveGid

func (o *Options) PreserveGid() bool
func (o *Options) PreserveHardLinks() bool
func (o *Options) PreserveLinks() bool

func (*Options) PreserveMTimes

func (o *Options) PreserveMTimes() bool

func (*Options) PreservePerms

func (o *Options) PreservePerms() bool

func (*Options) PreserveSpecials

func (o *Options) PreserveSpecials() bool

func (*Options) PreserveUid

func (o *Options) PreserveUid() bool

func (*Options) Recurse

func (o *Options) Recurse() bool

func (*Options) Sender

func (o *Options) Sender() bool

func (*Options) Server

func (o *Options) Server() bool

func (*Options) SetLocalServer

func (o *Options) SetLocalServer()

func (*Options) SetSender

func (o *Options) SetSender()

func (*Options) ShellCommand

func (o *Options) ShellCommand() string

func (*Options) UpdateOnly

func (o *Options) UpdateOnly() bool

func (*Options) Verbose

func (o *Options) Verbose() bool

type PoptError

type PoptError struct {
	Errno int32
	Err   error
}

func (*PoptError) Error

func (pe *PoptError) Error() string

func (*PoptError) Unwrap

func (pe *PoptError) Unwrap() error

Jump to

Keyboard shortcuts

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