Skip to content

feat: implement real-time CLI progress bar#362

Open
Raxyl00 wants to merge 2 commits into
xroche:masterfrom
Raxyl00:feat/cli-progress-bar
Open

feat: implement real-time CLI progress bar#362
Raxyl00 wants to merge 2 commits into
xroche:masterfrom
Raxyl00:feat/cli-progress-bar

Conversation

@Raxyl00

@Raxyl00 Raxyl00 commented Jun 15, 2026

Copy link
Copy Markdown

This PR implements a real-time progress bar for the CLI client (httrack) under verbose mode (-%v1).

Changes

  • Implemented print_progress_bar as a private static helper in src/httrack.c.
  • Displays completion percentage, visual bar [=====> ], link counters, download speed (KB/s), and calculated ETA.
  • Added instant redrawing on link count updates to avoid any lag or flickering.
  • Configured file completion logs in src/htsback.c and src/htsparse.c to end with \n instead of \r. This is a deliberate change to allow normal terminal scrollback for completed logs while keeping the progress bar cleanly positioned at the bottom of the screen.
  • Complies with C89 formatting and uses safe string APIs (snprintf and strcpybuff).
  • Uses standard ASCII symbols only (DL: instead of non-ASCII down-arrows) to ensure cross-platform terminal compatibility.

@xroche

xroche commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Thanks for this, nice idea, and the \r->\n change reads cleanly. Two things need fixing before it can land:

  1. Premature "100%" mid-crawl. lien_tot isn't fixed: the engine grows it as it discovers links while parsing each page. So on the first page lien_n reaches lien_tot (1==1) before any children are found, and the lien_n == lien_tot block latches finished and prints a newline. Then lien_tot grows, finished resets, and the bar restarts. You get a stray "100%" line every time the done-count momentarily catches the known-link count. Completion should come from htsshow_end (which already passes lien_tot, lien_tot), not from the per-loop equality check.
  2. OOB write on negative lien_n. percent is clamped on the high side but not the low side, so a negative lien_n produces a negative filled, and bar_str[filled] = '>' writes before the array. A low clamp (or a filled >= 0 guard) fixes it.

Two smaller things: reset the statics at mirror start so a second mirror in the same process doesn't inherit a stale finished, and add a unit test driving a 1,1 then 1,N call sequence to lock down the completion logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants