Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Honor `--` when extracting crawlctl global flags so flag-like job names remain literal selections instead of changing CLI behavior.

- Report a failed job when all configured `{repo}` values are blank instead of silently succeeding without running anything.

- Reject Windows Task Scheduler intervals above 1439 minutes during planning instead of producing unsupported minute-mode commands.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ applies private file permissions before replacing existing content.
| `install` | Install or render a periodic schedule |
| `uninstall` | Remove an installed periodic schedule |

Use `crawlctl run -- JOB` for job names that look like global flags. Global flags
before `--` retain their normal behavior; names after it stay literal.

Scheduling uses launchd on macOS, systemd user units on Linux, Task Scheduler on Windows, and cron rendering as the portable fallback. Cron requires whole-minute intervals below one hour that divide 60 evenly, such as `5m`, `12m`, or `30m`; other intervals are rejected because minute steps restart each hour.

Launchd and systemd plans require whole-second intervals of at least one minute.
Expand Down
4 changes: 4 additions & 0 deletions cmd/crawlctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func hoistGlobalFlags(args []string) []string {
rest := make([]string, 0, len(args))
for i := 0; i < len(args); i++ {
arg := args[i]
if arg == "--" {
rest = append(rest, args[i:]...)
break
}
switch {
case arg == "--json" || arg == "--version":
out = append(out, arg)
Expand Down
49 changes: 49 additions & 0 deletions cmd/crawlctl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,52 @@ func TestRunJobsRejectsBlankRepositories(t *testing.T) {
})
}
}

func TestRunHonorsFlagSeparatorForJobNames(t *testing.T) {
exe, err := os.Executable()
if err != nil {
t.Fatal(err)
}
for _, name := range []string{"ordinary", "--version", "--json", "--config=literal"} {
for _, jsonOutput := range []bool{false, true} {
t.Run(fmt.Sprintf("%s/json=%t", name, jsonOutput), func(t *testing.T) {
configPath := filepath.Join(t.TempDir(), "crawlctl.toml")
jobName := name
if strings.HasPrefix(name, "--config=") {
jobName = "--config=" + filepath.Join(t.TempDir(), "missing.toml")
}
cfg := scheduler.DefaultConfig()
for _, job := range []string{jobName, "other"} {
cfg.Jobs[job] = scheduler.Job{Enabled: true, Command: []string{exe, "-test.run=^$"}}
}
paths, err := scheduler.Save(configPath, cfg, false)
if err != nil {
t.Fatal(err)
}
args := []string{"--config", configPath, "run"}
if jsonOutput {
args = append(args, "--json")
}
args = append(args, "--", jobName)
var stdout bytes.Buffer
a := app{stdout: &stdout, stderr: ioDiscard{}}
if err := a.run(t.Context(), args); err != nil {
t.Fatal(err)
}
history, err := scheduler.ReadHistory(paths.History)
if err != nil || len(history) != 1 || history[0].Job != jobName || history[0].Status != "success" {
t.Fatalf("selected job not run exclusively: %+v, %v", history, err)
}
if a.json != jsonOutput {
t.Fatalf("JSON mode = %t, want %t", a.json, jsonOutput)
}
if jsonOutput {
var records []scheduler.RunRecord
if err := json.Unmarshal(stdout.Bytes(), &records); err != nil || len(records) != 1 || records[0].Job != jobName {
t.Fatalf("JSON output = %q, %v", stdout.String(), err)
}
}
})
}
}
}
Loading