rlmgrep 0.1.24__tar.gz → 0.1.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rlmgrep
3
- Version: 0.1.24
3
+ Version: 0.1.27
4
4
  Summary: Grep-shaped CLI search powered by DSPy RLM
5
5
  Author: rlmgrep
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "rlmgrep"
3
- version = "0.1.24"
3
+ version = "0.1.27"
4
4
  description = "Grep-shaped CLI search powered by DSPy RLM"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.1.24"
2
+ __version__ = "0.1.27"
@@ -36,7 +36,7 @@ from .render import render_matches
36
36
 
37
37
 
38
38
  def _warn(msg: str) -> None:
39
- print(f"rlmgrep: {msg}", file=sys.stderr)
39
+ print(f"rlmgrep: {msg}", file=sys.stderr, flush=True)
40
40
 
41
41
 
42
42
  def _console() -> Console:
@@ -538,7 +538,6 @@ def main(argv: list[str] | None = None) -> int:
538
538
  _warn(w)
539
539
 
540
540
  console = _console()
541
- progress = None
542
541
 
543
542
  # Resolve input corpus.
544
543
  globs = _split_list(args.globs)
@@ -570,9 +569,9 @@ def main(argv: list[str] | None = None) -> int:
570
569
  return 2
571
570
  else:
572
571
  if sys.stdin.isatty():
573
- _warn("no input paths and stdin is empty")
574
- return 2
575
- stdin_text = sys.stdin.read()
572
+ input_paths = ["."]
573
+ else:
574
+ stdin_text = sys.stdin.read()
576
575
 
577
576
  if input_paths is None:
578
577
  text = stdin_text or ""
@@ -602,26 +601,31 @@ def main(argv: list[str] | None = None) -> int:
602
601
  ignore_spec = build_ignore_spec(ignore_root, extra_paths=extra_ignores)
603
602
 
604
603
  scan_task = None
605
- load_task = None
606
604
  scan_count = 0
605
+ scan_progress = None
607
606
  if sys.stderr.isatty():
608
- progress = Progress(
607
+ scan_progress = Progress(
609
608
  SpinnerColumn(),
610
609
  TextColumn("{task.description}"),
610
+ TextColumn("{task.completed} files"),
611
611
  BarColumn(),
612
612
  TaskProgressColumn(),
613
613
  TimeElapsedColumn(),
614
614
  console=console,
615
615
  transient=False,
616
616
  )
617
- progress.start()
618
- scan_task = progress.add_task("Scanning files", total=None)
617
+ scan_progress.start()
618
+ scan_task = scan_progress.add_task("Scanning files", total=None)
619
619
 
620
620
  def _scan_update(count: int) -> None:
621
621
  nonlocal scan_count
622
622
  scan_count = count
623
- if progress is not None and scan_task is not None:
624
- progress.update(scan_task, completed=count)
623
+ if scan_progress is not None and scan_task is not None:
624
+ scan_progress.update(
625
+ scan_task,
626
+ completed=count,
627
+ description=f"Scanning files ({count})",
628
+ )
625
629
 
626
630
  candidates, scanned = collect_candidates(
627
631
  input_paths,
@@ -632,21 +636,21 @@ def main(argv: list[str] | None = None) -> int:
632
636
  include_hidden=args.hidden,
633
637
  ignore_spec=ignore_spec,
634
638
  ignore_root=ignore_root,
635
- scan_progress=_scan_update if progress is not None else None,
639
+ scan_progress=_scan_update if scan_progress is not None else None,
636
640
  )
637
- if progress is not None and scan_task is not None:
638
- progress.update(
641
+ if scan_progress is not None and scan_task is not None:
642
+ scan_progress.update(
639
643
  scan_task,
640
644
  total=scanned or scan_count,
641
645
  completed=scanned or scan_count,
646
+ description=f"Scanning files ({scanned or scan_count})",
642
647
  )
648
+ scan_progress.stop()
643
649
  candidate_count = len(candidates)
644
650
  if hard_max is not None and candidate_count > hard_max:
645
651
  _warn(
646
652
  f"{candidate_count} files to load (over {hard_max}); aborting"
647
653
  )
648
- if progress is not None:
649
- progress.stop()
650
654
  return 2
651
655
  if (
652
656
  warn_threshold is not None
@@ -654,19 +658,40 @@ def main(argv: list[str] | None = None) -> int:
654
658
  and not args.yes
655
659
  ):
656
660
  if not _confirm_over_limit(candidate_count, warn_threshold):
657
- if progress is not None:
658
- progress.stop()
659
661
  return 2
660
- if progress is not None:
661
- load_task = progress.add_task(
662
+
663
+ load_task = None
664
+ load_progress = None
665
+ if sys.stderr.isatty():
666
+ load_progress = Progress(
667
+ SpinnerColumn(),
668
+ TextColumn("{task.description}"),
669
+ TextColumn("{task.completed}/{task.total} files"),
670
+ BarColumn(),
671
+ TaskProgressColumn(),
672
+ TimeElapsedColumn(),
673
+ console=console,
674
+ transient=False,
675
+ )
676
+ load_progress.start()
677
+ load_task = load_progress.add_task(
662
678
  "Loading files",
663
679
  total=candidate_count,
664
680
  completed=0,
665
681
  )
666
682
 
683
+ load_done = 0
684
+
667
685
  def _load_update(done: int, total: int) -> None:
668
- if progress is not None and load_task is not None:
669
- progress.update(load_task, completed=done, total=total)
686
+ nonlocal load_done
687
+ load_done = done
688
+ if load_progress is not None and load_task is not None:
689
+ load_progress.update(
690
+ load_task,
691
+ completed=done,
692
+ total=total,
693
+ description=f"Loading files ({done}/{total})",
694
+ )
670
695
 
671
696
  files, warnings = load_files(
672
697
  candidates,
@@ -676,10 +701,24 @@ def main(argv: list[str] | None = None) -> int:
676
701
  enable_audio=md_enable_audio,
677
702
  audio_transcriber=audio_transcriber,
678
703
  binary_as_text=args.binary_as_text,
679
- progress=_load_update if progress is not None else None,
704
+ progress=_load_update if load_progress is not None else None,
680
705
  )
681
- if progress is not None:
682
- progress.stop()
706
+ if load_progress is not None and load_task is not None:
707
+ load_progress.update(
708
+ load_task,
709
+ completed=load_done,
710
+ total=candidate_count,
711
+ description=f"Loading files ({load_done}/{candidate_count})",
712
+ )
713
+ load_progress.stop()
714
+
715
+ scanned_total = scanned or scan_count
716
+ loaded_total = len(files)
717
+ skipped_total = max(0, candidate_count - loaded_total)
718
+ summary = f"Scanned {scanned_total} files. Loaded {loaded_total}."
719
+ if skipped_total:
720
+ summary += f" Skipped {skipped_total}."
721
+ _warn(summary)
683
722
 
684
723
  for w in warnings:
685
724
  _warn(w)
@@ -792,7 +831,9 @@ def main(argv: list[str] | None = None) -> int:
792
831
  before = args.before if args.before is not None else args.context
793
832
  after = args.after if args.after is not None else args.context
794
833
 
795
- use_color = sys.stdout.isatty() and not os.getenv("NO_COLOR")
834
+ stdout_tty = sys.stdout.isatty()
835
+ stderr_tty = sys.stderr.isatty()
836
+ use_color = stdout_tty and not os.getenv("NO_COLOR")
796
837
 
797
838
  output_lines = render_matches(
798
839
  files=files,
@@ -803,13 +844,16 @@ def main(argv: list[str] | None = None) -> int:
803
844
  heading=True,
804
845
  )
805
846
 
806
- stdout_console = Console(force_terminal=use_color, color_system="auto")
847
+ stdout_console = Console(force_terminal=stdout_tty, color_system="auto")
807
848
  if args.answer and answer:
808
849
  _print_answer(console, answer)
809
850
 
810
- if use_color and sys.stdout.isatty():
851
+ if stdout_tty:
811
852
  _print_matches(stdout_console, output_lines, use_color=use_color)
812
- else:
853
+ elif stderr_tty:
854
+ _print_matches(console, output_lines, use_color=False)
855
+
856
+ if not stdout_tty:
813
857
  for line in output_lines:
814
858
  print(line)
815
859
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rlmgrep
3
- Version: 0.1.24
3
+ Version: 0.1.27
4
4
  Summary: Grep-shaped CLI search powered by DSPy RLM
5
5
  Author: rlmgrep
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes