-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transmission BitTorrent client completions (#2319)
* Added completer for transmission-cli * Added completer for transmission-edit * Added completer for transmission-show * Added completer for transmission-create * Added completer for transmission-daemon * Added completer for transmission-remote * Addressed code review - Refatored transmission.ActionIds to take []string instead of cobra command - Fixed typos of "magnet" - Removed unneccary batching of ActionFiles and ActionDirectories - Removed no-op call to style.ForKeyword - Removed shared action for `.Chdir("/")` - Renamed ActionFilter to ActionFilters - Removed micro-optimization that avoided append(...) - Fixed multiword completion in transmission-edit
- Loading branch information
Showing
14 changed files
with
621 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/transmission" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "transmission-cli [flags] torrent-file", | ||
Short: "A fast and easy BitTorrent client", | ||
Long: "https://transmissionbt.com/", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().BoolP("blocklist", "b", false, "Enable peer blocklists") | ||
rootCmd.Flags().StringP("config-dir", "g", "", "Directory to look for configuratinon files in") | ||
rootCmd.Flags().IntP("downlimit", "d", 0, "Set the maximum download speed in KB/s") | ||
rootCmd.Flags().StringP("download-dir", "w", "", "Where to save downloaded data") | ||
rootCmd.Flags().BoolP("encryption-preferred", "ep", false, "Prefer encrypted peer connections") | ||
rootCmd.Flags().BoolP("encryption-required", "er", false, "Encrypt all peer connections") | ||
rootCmd.Flags().BoolP("encryption-tolerated", "et", false, "Prefer unencrypted peer connections") | ||
rootCmd.Flags().StringP("finish", "f", "", "Set a script to run when the torrent finishes") | ||
rootCmd.Flags().BoolP("help", "h", false, "Prints a short usage summary") | ||
rootCmd.Flags().BoolP("no-blocklist", "B", false, "Disable peer blocklists") | ||
rootCmd.Flags().BoolP("no-downlimit", "D", true, "Don't limit the download speed") | ||
rootCmd.Flags().BoolP("no-portmap", "M", true, "Disable portmapping") | ||
rootCmd.Flags().BoolP("no-uplimit", "U", true, "Don't limit the upload speed") | ||
rootCmd.Flags().IntP("port", "p", 51413, "Set the port to listen for incoming peers") | ||
rootCmd.Flags().BoolP("portmap", "m", false, "Enable port mapping via NAT-PMP or UPnP") | ||
rootCmd.Flags().String("tos", "", "Use a ToS or DSCP name or value from 0-255 to set the peer socket service type") | ||
rootCmd.Flags().IntP("uplimit", "u", 0, "Set the maximum upload speed in KB/s") | ||
rootCmd.Flags().BoolP("verify", "v", true, "Verify the torrent's downloaded data") | ||
rootCmd.Flags().BoolP("version", "V", false, "Show version number and exit") | ||
|
||
rootCmd.MarkFlagsMutuallyExclusive("blocklist", "no-blocklist") | ||
rootCmd.MarkFlagsMutuallyExclusive("downlimit", "no-downlimit") | ||
rootCmd.MarkFlagsMutuallyExclusive("encryption-required", "encryption-preferred", "encryption-tolerated") | ||
rootCmd.MarkFlagsMutuallyExclusive("portmap", "no-portmap") | ||
rootCmd.MarkFlagsMutuallyExclusive("uplimit", "no-uplimit") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"config-dir": carapace.ActionDirectories().Chdir("/"), | ||
"download-dir": carapace.ActionDirectories().Chdir("/"), | ||
"finish": carapace.ActionFiles().Chdir("/"), | ||
"tos": transmission.ActionTOS(), | ||
}) | ||
carapace.Gen(rootCmd).PositionalCompletion(carapace.ActionFiles(".torrent", ".magnet")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/transmission-cli_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "transmission-create [flags] PATH", | ||
Short: "A command-line utility to create .torrent files", | ||
Long: "https://transmissionbt.com/", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().Bool("anonymize", false, "Omit the optional \"created by\" and \"created date\" keys") | ||
rootCmd.Flags().StringArrayP("comment", "c", nil, "Add a comment to the torrent file") | ||
rootCmd.Flags().BoolP("help", "h", false, "Show a short help page and exit") | ||
rootCmd.Flags().StringP("outfile", "o", "", "Name of output torrent file") | ||
rootCmd.Flags().IntP("piecesize", "s", 0, "Set the size of the torrent pieces in KiB") | ||
rootCmd.Flags().BoolP("private", "p", false, "Flag the torrent as intended for use on private trackers") | ||
rootCmd.Flags().StringP("source", "r", "", "Set the torrent's source for private trackers") | ||
rootCmd.Flags().StringArrayP("tracker", "t", nil, "Add a tracker's announce URL to the torrent") | ||
rootCmd.Flags().BoolP("version", "V", false, "Show version number and exit") | ||
rootCmd.Flags().StringArrayP("webseed", "w", nil, "Add a webseed URL") | ||
|
||
rootCmd.MarkFlagsMutuallyExclusive("source", "tracker") | ||
rootCmd.MarkFlagsOneRequired("source", "tracker") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"outfile": carapace.ActionFiles(".torrent"), | ||
}) | ||
carapace.Gen(rootCmd).PositionalCompletion( | ||
carapace.ActionFiles(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/transmission-create_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/net" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "transmission-daemon [flags]", | ||
Short: "A daemon-based BitTorrent client", | ||
Long: "https://transmissionbt.com/", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().StringSliceP("allowed", "a", []string{"127.0.0.1", "::1"}, "Allow RPC access to a comma-delimited whiteliste of IP addresses") | ||
rootCmd.Flags().BoolP("auth", "t", false, "Require clients to authenticate themselves") | ||
rootCmd.Flags().StringP("bind-address-ipv4", "i", "0.0.0.0", "Listen for IPv4 connections on a specific address") | ||
rootCmd.Flags().StringP("bind-address-ipv6", "I", "::/0", "Listen for IPv6 connections on a specific address") | ||
rootCmd.Flags().BoolP("blocklist", "b", false, "Enable peer blocklists") | ||
rootCmd.Flags().StringP("config-dir", "g", "", "Directory to look for configuratinon files in") | ||
rootCmd.Flags().BoolP("dht", "o", false, "Enable distributed hash table") | ||
rootCmd.Flags().StringP("download-dir", "w", "", "Where to save downloaded data") | ||
rootCmd.Flags().BoolP("dump", "d", false, "Dump transmission-daemon's settings to stderr") | ||
rootCmd.Flags().BoolP("encryption-preferred", "ep", false, "Prefer encrypted peer connections") | ||
rootCmd.Flags().BoolP("encryption-required", "er", false, "Encrypt all peer connections") | ||
rootCmd.Flags().BoolP("encryption-tolerated", "et", false, "Prefer unencrypted peer connections") | ||
rootCmd.Flags().BoolP("foreground", "f", false, "Run in the foreground and print errors to stderr") | ||
rootCmd.Flags().StringS("watch", "c", "", "Directory to watch for new .torrent files to be added") | ||
rootCmd.Flags().Float64S("global-seedratio", "gsr", 0, "All torrents, unless overriden by a per-torrent setting, should seed until this ratio") | ||
rootCmd.Flags().BoolP("help", "h", false, "Prints a short usage summary") | ||
rootCmd.Flags().String("incomplete-dir", "", "When adding new torrents, store their contents in directory until torrent is done") | ||
rootCmd.Flags().Bool("log-debug", false, "Show error, info, and debug messages") | ||
rootCmd.Flags().Bool("log-error", false, "Show error messages") | ||
rootCmd.Flags().Bool("log-info", false, "Show error and info messages") | ||
rootCmd.Flags().StringP("logfile", "e", "", "Where to send log output") | ||
rootCmd.Flags().BoolP("no-auth", "T", false, "Don't require authentication from clients") | ||
rootCmd.Flags().BoolP("no-blocklist", "B", false, "Disable peer blocklists") | ||
rootCmd.Flags().BoolP("no-dht", "O", false, "Disable distributed hash table") | ||
rootCmd.Flags().BoolP("no-global-seedratio", "GSR", false, "All torrents, unless overriden by a per-torrent setting, should seed regardless of ratio") | ||
rootCmd.Flags().Bool("no-incomplete-dir", false, "Don't store incomplete torrents in a different directory") | ||
rootCmd.Flags().BoolP("no-portmap", "M", true, "Disable portmapping") | ||
rootCmd.Flags().Bool("no-utp", false, "Disable uTP for peer connections") | ||
rootCmd.Flags().BoolS("no-watch", "C", false, "Do not watch for new .torrent files") | ||
rootCmd.Flags().StringP("password", "v", "", "Client authentication password") | ||
rootCmd.Flags().Bool("paused", false, "Pause all torrents on startup") | ||
rootCmd.Flags().IntP("peerport", "P", 51413, "Set the port to listen for incoming peers") | ||
rootCmd.Flags().IntP("peerlimit-global", "L", 240, "Overall peer limit") | ||
rootCmd.Flags().IntP("peerlimit-torrent", "l", 60, "Peer limit per torrent") | ||
rootCmd.Flags().StringP("pid-file", "x", "", "Name of the daemon PID file") | ||
rootCmd.Flags().IntP("port", "p", 9091, "Port to open and listen for RPC requests on") | ||
rootCmd.Flags().BoolP("portmap", "m", false, "Enable port mapping via NAT-PMP or UPnP") | ||
rootCmd.Flags().StringP("rpc-bind-address", "r", "0.0.0.0", "Listen for RPC connections on a specific IPv4 or IPv6 address") | ||
rootCmd.Flags().StringP("username", "u", "", "Client authentication username") | ||
rootCmd.Flags().Bool("utp", false, "Enable uTP for peer connections") | ||
rootCmd.Flags().BoolP("version", "V", false, "Show version number and exit") | ||
|
||
rootCmd.MarkFlagsMutuallyExclusive("auth", "no-auth") | ||
rootCmd.MarkFlagsMutuallyExclusive("blocklist", "no-blocklist") | ||
rootCmd.MarkFlagsMutuallyExclusive("dht", "no-dht") | ||
rootCmd.MarkFlagsMutuallyExclusive("encryption-required", "encryption-preferred", "encryption-tolerated") | ||
rootCmd.MarkFlagsMutuallyExclusive("global-seedratio", "no-global-seedratio") | ||
rootCmd.MarkFlagsMutuallyExclusive("incomplete-dir", "no-incomplete-dir") | ||
rootCmd.MarkFlagsMutuallyExclusive("log-error", "log-info", "log-debug") | ||
rootCmd.MarkFlagsMutuallyExclusive("portmap", "no-portmap") | ||
rootCmd.MarkFlagsMutuallyExclusive("utp", "no-utp") | ||
rootCmd.MarkFlagsMutuallyExclusive("watch", "no-watch") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"allowed": net.ActionIpv4Addresses(), | ||
"bind-address-ipv4": net.ActionIpv4Addresses(), | ||
"bind-address-ipv6": carapace.ActionValues("::0/0", "fe80::/10"), | ||
"config-dir": carapace.ActionDirectories().Chdir("/"), | ||
"download-dir": carapace.ActionDirectories().Chdir("/"), | ||
"logfile": carapace.ActionFiles().Chdir("/"), | ||
"pid-file": carapace.ActionFiles().Chdir("/"), | ||
"rpc-bind-address": net.ActionIpv4Addresses(), | ||
"watch": carapace.ActionDirectories().Chdir("/"), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/transmission-daemon_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "transmission-edit [flags] torrentfile...", | ||
Short: "A command-line utility to modify .torrent files' announce URLs", | ||
Long: "https://transmissionbt.com/", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().StringP("add", "a", "", "Add an announce URL to the torrent's announce-list") | ||
rootCmd.Flags().StringP("delete", "d", "", "Remove an announce URL from the torrent's announce-list") | ||
rootCmd.Flags().BoolP("help", "h", false, "Show a short help page and exit") | ||
rootCmd.Flags().StringSliceP("replace", "r", nil, "Substring search-and-replace inside a torrent's announce-list URLs") | ||
rootCmd.Flags().StringP("source", "s", "", "Sets the source tag within a torrent") | ||
rootCmd.Flags().BoolP("version", "V", false, "Show version number and exit") | ||
|
||
rootCmd.Flag("replace").Nargs = 2 | ||
|
||
carapace.Gen(rootCmd).PositionalAnyCompletion(carapace.ActionFiles(".torrent")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/transmission-edit_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
Oops, something went wrong.