Documentation ¶
Index ¶
- func DoAdd(args *Args, cmd string) error
- func DoBlocklistUpdate(args *Args) error
- func DoConfig(args *Args, cmd string) error
- func DoFilesGet(args *Args) error
- func DoFilesRename(args *Args) error
- func DoFilesSet(field string) func(args *Args) error
- func DoFilesSetPriority(args *Args) error
- func DoFreeSpace(args *Args) error
- func DoGet(args *Args, cmd string) error
- func DoMove(args *Args) error
- func DoPeersGet(args *Args) error
- func DoPortTest(args *Args) error
- func DoRemove(args *Args) error
- func DoReq(f func(...interface{}) *transrpc.Request) func(*Args) error
- func DoSet(args *Args, cmd string) error
- func DoShutdown(args *Args) error
- func DoStats(args *Args) error
- func DoTrackersAdd(args *Args) error
- func DoTrackersGet(args *Args) error
- func DoTrackersRemove(args *Args) error
- func DoTrackersReplace(args *Args) error
- func Register(name string, f func(*Args) (Provider, error))
- type Args
- type ConfigStore
- type Error
- type Provider
- type Result
- type ResultOption
- func ColumnNames(columnNames map[string]string) ResultOption
- func FlatIndex(flatIndex string) ResultOption
- func FlatKey(flatKey string) ResultOption
- func FlatName(flatName string) ResultOption
- func FormatBytes(formatBytes func(tctypes.ByteFormatter) string) ResultOption
- func Index(index string) ResultOption
- func NoHeaders(noHeaders bool) ResultOption
- func NoTotals(noTotals bool) ResultOption
- func Output(output string) ResultOption
- func SortBy(sortBy string, sortByWasSet bool) ResultOption
- func SortOrder(sortOrder string, sortOrderWasSet bool) ResultOption
- func TableColumns(tableCols ...string) ResultOption
- func WideColumns(wideCols ...string) ResultOption
- func YamlName(yamlName string) ResultOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoBlocklistUpdate ¶
DoBlocklistUpdate is the high-level entry point for 'blocklist-update'.
func DoFilesGet ¶
DoFilesGet is the high-level entry point for 'files get'.
func DoFilesRename ¶
DoFilesRename is the high-level entry point for 'files rename'.
func DoFilesSet ¶
DoFilesSet generates a torrent set request to change the specified field.
func DoFilesSetPriority ¶
DoFilesSetPriority is the high-level entry point for 'files set-priority'.
func DoFreeSpace ¶
DoFreeSpace is the high-level entry point for 'free-space'.
func DoPeersGet ¶
DoPeersGet is the high-level entry point for 'peers get'.
func DoPortTest ¶
DoPortTest is the high-level entry point for 'port-test'.
func DoShutdown ¶
DoShutdown is the high-level entry point for 'shutdown'.
func DoTrackersAdd ¶
DoTrackersAdd is the high-level entry point for 'trackers add'.
func DoTrackersGet ¶
DoTrackersGet is the high-level entry point for 'trackers get'.
func DoTrackersRemove ¶
DoTrackersRemove is the high-level entry point for 'trackers remove'.
func DoTrackersReplace ¶
DoTrackersReplace is the high-level entry point for 'trackers replace'.
Types ¶
type Args ¶
type Args struct { // ConfigFile is the global config file. ConfigFile string // Context is the global context name. Context string // Verbose is the global verbose toggle. Verbose bool // Host contains the global host configuration. Host struct { // URL is the URL to work with. URL *url.URL // Proto is the proto to use for building URLs. Proto string // Host is the host and port to use for building URLs. Host string // RpcPath is the rpc path to use for building URLs. RpcPath string // Credentials is the user:pass credentials to work with. Credentials string // CredentialsWasSet is the credentials was set toggle. CredentialsWasSet bool // Timeout is the rpc host request timeout. Timeout time.Duration // NoNetrc toggles disabling .netrc loading. NoNetrc bool // NetRCFile is the NetRCFile to use. NetrcFile string } // Filter contains the global filter configuration. Filter struct { // ListAll is the all toggle. ListAll bool // Recent is the recent toggle. Recent bool // Filter is the torrent filter. Filter string // FilterWasSet is the filter set toggle. FilterWasSet bool } // Output contains the global output configuration. Output struct { // Output is the output format type. Output string // OutputWasSet is the output was set toggle. OutputWasSet bool // Human is the toggle to display sizes in powers of 1024 (ie, 1023MiB). Human string // SI is the toggle to display sizes in powers of 1000 (ie, 1.1GB). SI bool // SIWasSet is the si was set toggle. SIWasSet bool // NoHeaders is the toggle to disable headers on table output. NoHeaders bool // NoTotals is the toggle to disable the total line on table output. NoTotals bool // ColumnNames is the column name map. ColumnNames map[string]string // SortBy is the to sort by field. SortBy string // SortByWasSet is the sort by was set toggle. SortByWasSet bool // SortOrder is the sort order direction. SortOrder string // SortOrderWasSet is the sort order was set toggle SortOrderWasSet bool } // ConfigParams are the config params. ConfigParams struct { Remote bool Name string Value string Unset bool } // AddParams are the add params. AddParams struct { Cookies map[string]string DownloadDir string Paused bool PeerLimit int64 BandwidthPriority int64 Remove bool RemoveWasSet bool } // StartParams are the start params. StartParams struct { Now bool } // MoveParams are the move params. MoveParams struct { Dest string } // RemoveParams are the remove params. RemoveParams struct { Remove bool } // FilesSetPriorityParams are the files set-priority params. FilesSetPriorityParams struct { Priority string } // FilesRenameParams are the files rename params. FilesRenameParams struct { OldPath string NewPath string } // TrackersReplacePramas are the trackers replace params. TrackersReplaceParams struct { Replace string } // FileMask is the file mask for files operations. FileMask string // Tracker is the tracker for trackers operations. Tracker string // Args are remaining global arguments. Args []string // Config is the loaded settings from the config file. Config *ini.File // contains filtered or unexported fields }
Args holds command args.
func (*Args) NewProvider ¶
NewProvider creates a new provider based on the configured type of the remote host.
func (*Args) ResultOptions ¶
func (args *Args) ResultOptions(opts ...ResultOption) []ResultOption
ResultOptions builds result options for arguments.
type ConfigStore ¶
type ConfigStore interface { GetKey(string) string SetKey(string, string) RemoveKey(string) GetMapFlat() map[string]string GetAllFlat() []string Write(string) error }
ConfigStore is the interface for config stores.
type Error ¶
type Error string
Error is the error type.
const ( // ErrMustSpecifyListRecentFilterOrAtLeastOneTorrent is the must specify // list, recent, filter or at least one torrent error. ErrMustSpecifyListRecentFilterOrAtLeastOneTorrent Error = "must specify --list, --recent, --filter or at least one torrent" // ErrMustSpecifyListOrOptionName is the must specify list or option name // error. ErrMustSpecifyListOrOptionName Error = "must specify --list or option name" // ErrConfigFileCannotBeADirectory is the config file cannot be a directory // error. ErrConfigFileCannotBeADirectory Error = "config file cannot be a directory" // ErrMustSpecifyAtLeastOneLocation is the must specify at least one // location error. ErrMustSpecifyAtLeastOneLocation Error = "must specify at least one location" // ErrCannotSpecifyUnsetAndAlsoSetAnOptionValue is the cannot specify unset // and also set an option value error. ErrCannotSpecifyUnsetAndAlsoSetAnOptionValue Error = "cannot specify --unset and also set an option value" // ErrInvalidProtoHostOrRpcPath is the invalid proto, host, or rpc-path // error. ErrInvalidProtoHostOrRpcPath Error = "invalid --proto, --host, or --rpc-path" // ErrCannotListAllOptionsAndUnset is the cannot list all options and unset // error. ErrCannotListAllOptionsAndUnset Error = "cannot --list all options and --unset" // ErrCannotUnsetARemoteConfigOption is the cannot unset a remote config // option error. ErrCannotUnsetARemoteConfigOption Error = "cannot --unset a --remote config option" // ErrMustSpecifyConfigOptionNameToUnset is the must specify config option // name to unset error. ErrMustSpecifyConfigOptionNameToUnset Error = "must specify config option name to --unset" // ErrInvalidOutputOptionSpecified is the invalid output option specified // error. ErrInvalidOutputOptionSpecified Error = "invalid --output option specified" // ErrSortByNotInColumnList is the sort by not in column list error. ErrSortByNotInColumnList Error = "--sort-by not in column list" // ErrMustSpecifyAtLeastOneOutputColumn is the must specify at least one output column error. ErrMustSpecifyAtLeastOneOutputColumn Error = "must specify at least one output column" // ErrFilterMustReturnBool is the filter must return bool error. ErrFilterMustReturnBool Error = "filter must return bool" // ErrInvalidStrlenArguments is the invalid strlen arguments error. ErrInvalidStrlenArguments Error = "invalid strlen() arguments" )
type Provider ¶
type Provider interface { // NewRemoteConfigStore creates a config store for the remote host. NewRemoteConfigStore(context.Context) (ConfigStore, error) // Add adds a torrent ([]byte) or magnet link (string). Add(context.Context, ...interface{}) ([]tctypes.Torrent, error) // Get returns a semi-populated torrent list, with the provided fields. Get(context.Context, []string, ...interface{}) ([]tctypes.Torrent, error) // Set sets a configuration option on a torrent. Set(context.Context, map[string]interface{}) error // Start starts the provided identifiers. Start(context.Context, ...interface{}) error // Stop stops the provided identifiers. Stop(context.Context, ...interface{}) error // Move moves the provided identifiers Move(context.Context, string, ...interface{}) error // Remove removes the provided identifiers. Remove(context.Context, bool, ...interface{}) error // Verify verifies the provided identifiers. Verify(context.Context, ...interface{}) error // Reannounce reannounces the provided identifiers. Reannounce(context.Context, ...interface{}) error // Queue sets the queue position (top, bottom, up, down) for the provided identifiers. Queue(context.Context, string, ...interface{}) error // PeersGet returns the peers for the provided identifiers. PeersGet(context.Context, ...interface{}) ([]tctypes.Peer, error) // FilesGet returns the files for the provided identifiers. FilesGet(context.Context, ...interface{}) ([]tctypes.File, error) // FilesSet sets a file config option on the provided identifiers. FilesSet(context.Context, map[string]interface{}, ...interface{}) error // FilesRename renames a file on the provided identifiers. FilesRename(context.Context, string, string, ...interface{}) error // TrackersGet returns the trackers for the provided identifiers. TrackersGet(context.Context, ...interface{}) ([]tctypes.Tracker, error) // TrackersAdd adds a tracker to the provided identifiers. TrackersAdd(context.Context, string, ...interface{}) error // TrackersReplace replaces a tracker on the provided identifiers. TrackersReplace(context.Context, string, string, ...interface{}) error // TrackersRemove removes a tracker from the provided identifiers. TrackersRemove(context.Context, string, ...interface{}) error // Stats returns the stats for the remote host. Stats(context.Context) (map[string]interface{}, error) // Shutdown shuts down the remote host. Shutdown(context.Context) error // FreeSpace returns the free space for the provided location. FreeSpace(context.Context, string) (tctypes.ByteCount, error) // BlocklistUpdate tells the remote host to update its blocklist. BlocklistUpdate(context.Context) (int64, error) // PortTest tells the remote to do a port test. PortTest(context.Context) (bool, error) }
Provider is a torrent provider.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is a wraper for a slice of structs. Uses reflection to iterate the items and output based on
func NewResult ¶
func NewResult(v interface{}, options ...ResultOption) *Result
NewResult creates a new reflection result for v.
type ResultOption ¶
type ResultOption = func(*Result)
ResultOption is a result option.
func ColumnNames ¶
func ColumnNames(columnNames map[string]string) ResultOption
ColumnNames is a result option to set the column names map.
func FlatIndex ¶
func FlatIndex(flatIndex string) ResultOption
FlatIndex is a result option to set the flat index key.
func FlatKey ¶
func FlatKey(flatKey string) ResultOption
FlatKey is a result option to set the flat key field.
func FlatName ¶
func FlatName(flatName string) ResultOption
FlatName is a result option to set the flat key used for output.
func FormatBytes ¶
func FormatBytes(formatBytes func(tctypes.ByteFormatter) string) ResultOption
FormatBytes is a result option to set the func used to format bytes.
func NoHeaders ¶
func NoHeaders(noHeaders bool) ResultOption
NoHeaders is a result option to set the no headers toggle.
func NoTotals ¶
func NoTotals(noTotals bool) ResultOption
NoTotals is a result option to set the no totals toggle.
func Output ¶
func Output(output string) ResultOption
Output is a result option to set the output format.
func SortBy ¶
func SortBy(sortBy string, sortByWasSet bool) ResultOption
SortBy is a result option to set the sort by field.
func SortOrder ¶
func SortOrder(sortOrder string, sortOrderWasSet bool) ResultOption
SortOrder is a result option to set the sort order direction (asc or desc).
func TableColumns ¶
func TableColumns(tableCols ...string) ResultOption
TableColumns is a result option to set the table column output.
func WideColumns ¶
func WideColumns(wideCols ...string) ResultOption
WideColumns is a result option to set the wide column output.
func YamlName ¶
func YamlName(yamlName string) ResultOption
YamlName is a result option to set the yaml key used for yaml output.