Skip to content

Commit c910e1c

Browse files
Rename --since flag to --report-since for clarity (#31)
Rename --since flag to --report-since for clarity
1 parent a41e2b4 commit c910e1c

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ gitstreams
4141
| `-db` | Path to SQLite database (default: `~/.gitstreams/gitstreams.db`) |
4242
| `-report` | Path to write HTML report (default: temp file) |
4343
| `-sync-lookback-days` | How far back to fetch GitHub data (1-365 days, default: 30) |
44+
| `-report-since` | Generate report from historical data starting from this date (e.g., `2026-01-15` or `7d` for 7 days ago) |
4445
| `-offline` | Skip GitHub API sync and use cached data |
4546
| `-no-notify` | Skip desktop notification |
4647
| `-no-open` | Don't open report in browser |
@@ -58,6 +59,12 @@ gitstreams -v -db /path/to/my.db
5859
# Fetch GitHub data from the last 7 days
5960
gitstreams -sync-lookback-days 7
6061

62+
# Generate report from historical cached data (last 7 days)
63+
gitstreams -report-since 7d
64+
65+
# Generate report from a specific date using cached data
66+
gitstreams -report-since 2026-01-15 -offline
67+
6168
# Use cached data without hitting GitHub API (fast, but may be stale)
6269
gitstreams -offline
6370
```

main.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ var (
3636

3737
// Config holds the runtime configuration for gitstreams.
3838
type Config struct {
39-
DBPath string
40-
Token string
41-
ReportPath string
42-
Since string // Generate report from this date (e.g., '2026-01-15' or '7d')
43-
Days int // How far back to fetch GitHub data (API sync lookback, default 30)
44-
NoNotify bool
45-
NoOpen bool
46-
Verbose bool
47-
Offline bool // Use only cached data, skip GitHub API calls
39+
DBPath string
40+
Token string
41+
ReportPath string
42+
ReportSince string // Generate report from this date (e.g., '2026-01-15' or '7d')
43+
Days int // How far back to fetch GitHub data (API sync lookback, default 30)
44+
NoNotify bool
45+
NoOpen bool
46+
Verbose bool
47+
Offline bool // Use only cached data, skip GitHub API calls
4848
}
4949

5050
// Dependencies holds injectable dependencies for testing.
@@ -134,11 +134,11 @@ func run(stdout, stderr io.Writer, args []string, deps *Dependencies) int {
134134
var currentSnapshot, previousSnapshot *diff.Snapshot
135135

136136
// Historical mode: generate report from cached data
137-
if cfg.Since != "" {
137+
if cfg.ReportSince != "" {
138138
var sinceDate time.Time
139-
sinceDate, err = parseSinceDate(cfg.Since, deps.Now())
139+
sinceDate, err = parseSinceDate(cfg.ReportSince, deps.Now())
140140
if err != nil {
141-
_, _ = fmt.Fprintf(stderr, "Error parsing --since date: %v\n", err)
141+
_, _ = fmt.Fprintf(stderr, "Error parsing --report-since date: %v\n", err)
142142
return 1
143143
}
144144

@@ -150,11 +150,11 @@ func run(stdout, stderr io.Writer, args []string, deps *Dependencies) int {
150150
var sinceSnapshots []*storage.Snapshot
151151
sinceSnapshots, err = store.GetByTimeRange(snapshotUserID, sinceDate.Add(-24*time.Hour), sinceDate.Add(24*time.Hour))
152152
if err != nil {
153-
_, _ = fmt.Fprintf(stderr, "Error querying snapshots for --since date: %v\n", err)
153+
_, _ = fmt.Fprintf(stderr, "Error querying snapshots for --report-since date: %v\n", err)
154154
return 1
155155
}
156156
if len(sinceSnapshots) == 0 {
157-
_, _ = fmt.Fprintf(stderr, "No cached snapshot found for date %s (try running without --since first to build cache)\n", sinceDate.Format("2006-01-02"))
157+
_, _ = fmt.Fprintf(stderr, "No cached snapshot found for date %s (try running without --report-since first to build cache)\n", sinceDate.Format("2006-01-02"))
158158
return 1
159159
}
160160
previousSnapshot, err = storageToSnapshot(sinceSnapshots[0])
@@ -279,11 +279,11 @@ func run(stdout, stderr io.Writer, args []string, deps *Dependencies) int {
279279
// Filter results by since date if specified
280280
// This is needed because snapshots contain historical data (e.g., 30 days),
281281
// so we need to filter out activities that occurred before the since date
282-
if cfg.Since != "" {
282+
if cfg.ReportSince != "" {
283283
var filterDate time.Time
284-
filterDate, err = parseSinceDate(cfg.Since, deps.Now())
284+
filterDate, err = parseSinceDate(cfg.ReportSince, deps.Now())
285285
if err != nil {
286-
_, _ = fmt.Fprintf(stderr, "Error parsing --since date for filtering: %v\n", err)
286+
_, _ = fmt.Fprintf(stderr, "Error parsing --report-since date for filtering: %v\n", err)
287287
return 1
288288
}
289289
result = filterResultBySinceDate(result, filterDate)
@@ -374,7 +374,7 @@ func parseFlags(args []string) (*Config, error) {
374374
fs.BoolVar(&cfg.Verbose, "v", false, "Verbose output")
375375
fs.BoolVar(&showVersion, "version", false, "Print version and exit")
376376
fs.IntVar(&cfg.Days, "sync-lookback-days", 30, "How far back to fetch GitHub data (1-365 days, doesn't affect report filtering)")
377-
fs.StringVar(&cfg.Since, "since", "", "Generate report from historical data (e.g., '2026-01-15' or '7d' for 7 days ago)")
377+
fs.StringVar(&cfg.ReportSince, "report-since", "", "Generate report from historical data starting from this date (e.g., '2026-01-15' or '7d' for 7 days ago)")
378378
fs.BoolVar(&cfg.Offline, "offline", false, "Use only cached data, skip GitHub API calls")
379379

380380
if err := fs.Parse(args); err != nil {

main_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ func TestRun_HistoricalMode(t *testing.T) {
12811281
}
12821282

12831283
var stdout, stderr bytes.Buffer
1284-
args := []string{"-since", "7d", "-token", "test-token", "-no-notify", "-no-open", "-v"}
1284+
args := []string{"-report-since", "7d", "-token", "test-token", "-no-notify", "-no-open", "-v"}
12851285

12861286
exitCode := run(&stdout, &stderr, args, deps)
12871287

@@ -1354,7 +1354,7 @@ func TestRun_OfflineMode(t *testing.T) {
13541354
}
13551355

13561356
var stdout, stderr bytes.Buffer
1357-
args := []string{"-since", "7d", "-offline", "-no-notify", "-no-open", "-v"}
1357+
args := []string{"-report-since", "7d", "-offline", "-no-notify", "-no-open", "-v"}
13581358

13591359
exitCode := run(&stdout, &stderr, args, deps)
13601360

@@ -1372,9 +1372,9 @@ func TestRun_OfflineMode(t *testing.T) {
13721372
}
13731373
}
13741374

1375-
// TestRun_OfflineWithoutSince - --offline can be used standalone or with --since
1375+
// TestRun_OfflineWithoutSince - --offline can be used standalone or with --report-since
13761376
// Standalone --offline mode uses cached data for a quick report without GitHub API calls
1377-
// This test is removed as --offline is now supported both with and without --since
1377+
// This test is removed as --offline is now supported both with and without --report-since
13781378

13791379
func TestRun_BrowserError_DoesNotFail(t *testing.T) {
13801380
var stdout, stderr bytes.Buffer

0 commit comments

Comments
 (0)