Skip to content

Commit decf15d

Browse files
author
Fletcher Aksel
committed
add --start-priority option
qbitorrent imports these lists with priority reflecting the order in the input list. --start-priority 10 will output 10 blank lines to set the tracker prioritys starting at 10 use this to avoid merging newly added tracker priorities with existing ones Signed-off-by: Fletcher Aksel <[email protected]>
1 parent 47a714c commit decf15d

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

cmd/groups.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ var groupsCmd = &cobra.Command{
2020
RunE: runGroups,
2121
}
2222

23+
var startPriority int
24+
2325
func init() {
2426
rootCmd.AddCommand(groupsCmd)
27+
groupsCmd.Flags().IntVarP(&startPriority, "start-priority", "p", 0, "Output N blank lines before tracker groups (default: 0)")
2528
}
2629

2730
func runGroups(cmd *cobra.Command, args []string) error {
31+
// Validate start-priority flag
32+
if startPriority < 0 {
33+
return fmt.Errorf("start-priority must be a non-negative integer, got: %d", startPriority)
34+
}
35+
2836
// Load config
2937
cfg, err := config.Load()
3038
if err != nil {
@@ -81,10 +89,24 @@ func runGroups(cmd *cobra.Command, args []string) error {
8189
}
8290
}()
8391

92+
// Output blank lines for start-priority
93+
if err := outputStartPriority(writer, startPriority); err != nil {
94+
return err
95+
}
96+
8497
// Output groups
8598
return outputGroups(writer, groups)
8699
}
87100

101+
func outputStartPriority(writer io.Writer, count int) error {
102+
for i := 0; i < count; i++ {
103+
if _, err := fmt.Fprintln(writer); err != nil {
104+
return err
105+
}
106+
}
107+
return nil
108+
}
109+
88110
func outputGroups(writer io.Writer, groups []group.Group) error {
89111
for i, g := range groups {
90112
if i > 0 {

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var outputFile string
1818

1919
func init() {
2020
rootCmd.PersistentFlags().StringVarP(&outputFile, "output", "o", "", "Write output to file instead of stdout")
21+
rootCmd.Flags().IntVarP(&startPriority, "start-priority", "p", 0, "Output N blank lines before tracker groups (default: 0)")
2122
}
2223

2324
// Execute runs the root command

prompts/02-start-priority.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Feature Addition: Start Priority Flag
2+
3+
Add a new flag to the `groups` command that outputs N blank lines before the grouped tracker URLs.
4+
5+
### Flag Specification
6+
- `--start-priority <number>` or `-p <number>`
7+
- Takes an integer argument (number of blank lines to output)
8+
- Only applies to the `groups` command (default command)
9+
- Works with both stdout and file output (`-o` flag)
10+
11+
### Behavior
12+
- Output N blank lines at the very beginning, before any tracker groups
13+
- Then output the normal grouped tracker URLs as usual
14+
- Example: `gettrackers groups --start-priority 10` outputs 10 blank lines, then the tracker groups
15+
16+
### Use Case
17+
This creates N "empty groups" that offset the priority of added trackers in clients like qBittorrent, effectively lowering the priority of the new trackers.
18+
19+
### Implementation Notes
20+
- Validate that the number is non-negative (0 or positive integer)
21+
- If invalid number provided, show clear error message
22+
- Default value should be 0 (no blank lines) if flag not specified
23+
- The blank lines should come before any other output, including the first tracker group
24+
25+
### Example Output
26+
```
27+
gettrackers groups -p 3
28+
```
29+
30+
Would output:
31+
```
32+
[blank line]
33+
[blank line]
34+
[blank line]
35+
http://tracker1.example.com:8080/announce
36+
http://tracker1.example.com:9090/announce
37+
38+
http://api.other.com/tracker
39+
...
40+
```

0 commit comments

Comments
 (0)