Skip to content

Commit 110e3f6

Browse files
committed
feat: improve CLI defaults for dogfooding ergonomics
Single-file output now defaults to the input image's parent directory instead of cwd, so `uitag /path/to/image.png` drops output beside the image. Batch command path argument defaults to current directory, so `uitag batch` with no args processes all images in cwd.
1 parent 8e1a7b0 commit 110e3f6

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

tests/test_batch_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ def test_format_summary_no_failures():
125125
assert "failed" not in summary
126126

127127

128-
def test_batch_main_no_args_exits():
129-
"""batch_main with no image path prints usage and exits."""
128+
def test_batch_main_no_args_defaults_to_cwd(tmp_path, monkeypatch):
129+
"""batch_main with no args defaults to current directory."""
130130
from uitag.batch_cli import batch_main
131131

132+
# Empty dir → exits with "No images found"
133+
monkeypatch.chdir(tmp_path)
132134
with pytest.raises(SystemExit) as exc:
133135
batch_main([])
134136
assert exc.value.code != 0

uitag/batch_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ def batch_main(argv: list[str] | None = None) -> None:
8282
)
8383
parser.add_argument(
8484
"path",
85-
nargs="+",
86-
help="Directory containing images, or individual image paths",
85+
nargs="*",
86+
default=["."],
87+
help="Directory containing images, or individual image paths (default: current directory)",
8788
)
8889
parser.add_argument(
8990
"--output-dir",

uitag/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ def main():
4343

4444
parser = argparse.ArgumentParser(description="uitag Detection Pipeline")
4545
parser.add_argument("image", help="Path to screenshot")
46-
parser.add_argument("--output-dir", "-o", default=".", help="Output directory")
46+
parser.add_argument(
47+
"--output-dir",
48+
"-o",
49+
default=None,
50+
help="Output directory (default: same directory as input image)",
51+
)
4752
parser.add_argument("--task", default="<OD>", help="Florence-2 task token")
4853
parser.add_argument(
4954
"--overlap", type=int, default=50, help="Quadrant overlap pixels"
@@ -82,7 +87,11 @@ def main():
8287
print(f"Error: Image not found: {image_path}", file=sys.stderr)
8388
sys.exit(1)
8489

85-
out_dir = Path(args.output_dir)
90+
# Default output dir: same directory as the input image
91+
if args.output_dir is None:
92+
out_dir = Path(image_path).parent.resolve()
93+
else:
94+
out_dir = Path(args.output_dir)
8695
out_dir.mkdir(parents=True, exist_ok=True)
8796

8897
from uitag.backends.selector import BackendPreference, select_backend

0 commit comments

Comments
 (0)