Skip to content

feat(cli): cargo-style colored output and live build progress - #89

Merged
wiseodd merged 8 commits into
mainfrom
feat/pretty-cli
Nov 28, 2026
Merged

wiseodd merged 8 commits into
mainfrom
feat/pretty-cli

Conversation

@wiseodd

@wiseodd wiseodd commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Stacked on #88 (which is stacked on #87): the first four commits are theirs. After they merge, this diff shows only the four commits below.

All mogs output gets one look, in the style of cargo and uv.

  • feat(cli): colored help and usage errors. A style module in mogs-cli holds the palette (anstyle) and one pure function, caps, that decides per stream whether to use color, a spinner and Unicode: color needs a terminal with a usable TERM (not unset, empty or dumb) and no NO_COLOR; Unicode needs a UTF-8 stream, TERM other than linux, and on Windows, Windows Terminal (WT_SESSION); on Windows the console must accept ANSI codes. clap's help and errors use cargo's colors, help texts are capitalized, and the help ends with a link to the docs.
  • feat(cli): cargo-style errors, init and edit output. Failures print error: Build failed with the message indented under it. init prints Created … and the next steps; edit prints warning: … and Opening … in marimo.
  • feat(build): styled build report. The upload and student paths, the question table with a rule and total, the hand-graded questions and warning: … lines. The rule is ─ only on a Unicode color terminal, else -, so a redirected report on Windows (cp1252) no longer crashes. "All done!" is gone.
  • feat(build): live progress. mogs-build reports its steps (Reading, Resolving, Checking, Testing solved notebook, Testing blank notebook, Packing) through a Progress trait; crates/mogs draws them with indicatif on stderr: a spinner on a capable terminal, plain step lines on a dumb terminal, nothing when piped. The spinner is cleared around Python calls that may print, on errors, on Ctrl-C and before a panic message.

Checked by recording real output with script under xterm-256color, TERM=dumb, TERM unset, TERM=linux, NO_COLOR=1, LANG=C, piped, cp1252 redirected, and a notebook that triggers a SyntaxWarning: no stray escapes, braille or leftover frames where the stream can't show them. Not run on a real Windows console.

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking fix needed for builds whose stdout is disabled.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes reach the `mogs` command-line workflows, especially assignment builds.

The PR appears safe to merge, with a non-blocking fix needed for builds whose stdout is disabled.

Findings

  1. P2 Disabled stdout stops builds ▶

Summary

Adds shared colors for help, errors, command messages, and build reports.

  • Builds check whether the blank student notebook already earns points.
  • Builds show each step as it runs, with progress suited to the terminal.
  • CLI help, errors, build reports, and setup messages share a terminal-aware style.
  • Autograde shows a plain error when its source folder is missing.

Acknowledged choices: wiseodd explicitly describes the stacked PRs and the lack of testing on a real Windows console. Neither is reported as a defect.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Read notebook] --> B[Resolve environment]
  B --> C[Check both notebooks]
  C --> D[Test solved notebook]
  D --> E[Test blank notebook]
  E --> F[Pack archives]
  F --> G[Print report]
  A -.-> P[Progress on terminal stderr]
  B -.-> P
  C -.-> P
  D -.-> P
  E -.-> P
  F -.-> P
Loading

Reviews (1) · Last reviewed commit: "feat(build): live progress" · Reviewed by Greptile

let notebook = found.str()?.to_string_lossy().into_owned();

let sys = py.import("sys")?;
sys.getattr("stdout")?.call_method0("flush")?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Disabled stdout stops builds

If a caller sets sys.stdout to None but leaves stderr attached to a terminal, live calls flush() on None. A valid build then raises AttributeError before it starts, even though caps_for accepts absent streams. Skip this flush when stdout is None so progress does not prevent the build from running.

Suggested change
sys.getattr("stdout")?.call_method0("flush")?;
let stdout = sys.getattr("stdout")?;
if !stdout.is_none() {
stdout.call_method0("flush")?;
}

@wiseodd
wiseodd merged commit 1d7cecb into main Nov 28, 2026
16 checks passed
@wiseodd
wiseodd deleted the feat/pretty-cli branch November 28, 2026 19:58
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.

1 participant