Skip to content

Commit

Permalink
Merge pull request #2328 from carapace-sh/transmission-port
Browse files Browse the repository at this point in the history
transmission: added port completion
  • Loading branch information
rsteube authored Apr 2, 2024
2 parents 9ff97c6 + 6197382 commit 9c1706f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions completers/transmission-cli_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/net"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/transmission"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -50,6 +51,7 @@ func init() {
"config-dir": carapace.ActionDirectories().Chdir("/"),
"download-dir": carapace.ActionDirectories().Chdir("/"),
"finish": carapace.ActionFiles().Chdir("/"),
"port": net.ActionPorts(),
"tos": transmission.ActionTOS(),
})
carapace.Gen(rootCmd).PositionalCompletion(carapace.ActionFiles(".torrent", ".magnet"))
Expand Down
1 change: 1 addition & 0 deletions completers/transmission-daemon_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func init() {
"download-dir": carapace.ActionDirectories().Chdir("/"),
"logfile": carapace.ActionFiles().Chdir("/"),
"pid-file": carapace.ActionFiles().Chdir("/"),
"port": net.ActionPorts(),
"rpc-bind-address": net.ActionIpv4Addresses(),
"watch": carapace.ActionDirectories().Chdir("/"),
})
Expand Down
12 changes: 11 additions & 1 deletion completers/transmission-remote_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,23 @@ func init() {
"move": carapace.ActionDirectories().Chdir("/"),
"netrc": carapace.ActionFiles(),
"no-get": carapace.ActionValuesDescribed("all", "Get all files").StyleF(style.ForKeyword),
"port": net.ActionKnownPorts(),
"torrent": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
filters, _ := rootCmd.Flags().GetStringArray("filter")
return transmission.ActionIds(filters)
}),
"torrent-done-script": carapace.ActionDirectories().Chdir("/"),
})
carapace.Gen(rootCmd).PositionalCompletion(net.ActionHosts())
carapace.Gen(rootCmd).PositionalCompletion(
carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return net.ActionHosts()
default:
return net.ActionKnownPorts()
}
}),
)
}

// Marks the flags so they're exclusive with --torrent
Expand Down

0 comments on commit 9c1706f

Please sign in to comment.