Skip to content

docs(cli): explain how to track a command in monitor --help - #1472

Merged
benoit-cty merged 1 commit into
mlco2:masterfrom
PRINCE2-AI:docs/monitor-help-track-command
Oct 31, 2026
Merged

benoit-cty merged 1 commit into
mlco2:masterfrom
PRINCE2-AI:docs/monitor-help-track-command

Conversation

@PRINCE2-AI

@PRINCE2-AI PRINCE2-AI commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

codecarbon monitor --help only printed "Monitor your machine's carbon emissions.", so the CLI never explained that monitor also wraps a command when arguments follow --.

That behaviour already exists — monitor() delegates to run_and_monitor() when extra args are present — and codecarbon/cli/monitor.py documents the patterns. Only the help text was missing. This adds a short overview line, the usage form, and a link to the "Track any command" section of the CLI tutorial.

Related Issue

Fixes #1470

Motivation and Context

uvx codecarbon monitor --help is the first place a user looks, but the documented feature at https://docs.codecarbon.io/latest/tutorials/cli/#track-any-command was invisible there.

Before:

 Usage: codecarbon monitor [OPTIONS]

 Monitor your machine's carbon emissions.

After:

 Usage: codecarbon monitor [OPTIONS]

 Monitor your machine's carbon emissions.

 To track a single command instead, pass it after a -- separator:
 codecarbon monitor -- python train.py
 Emissions are appended to the same emissions.csv report. See
 https://docs.codecarbon.io/latest/tutorials/cli/#track-any-command

How Has This Been Tested?

  • Ran uv run codecarbon monitor --help before the change (missing text) and after it, and checked the rendered help at several terminal widths.
  • Added test_monitor_help_explains_running_a_command in tests/cli/test_cli_main.py. It fails without the docstring change and passes with it.
  • uv run pytest tests/cli --basetemp=...: 80 passed. (The --basetemp is only because the default pytest temp directory is not writable on this Windows machine; unrelated to the change.)
  • uv run pre-commit run --files codecarbon/cli/main.py tests/cli/test_cli_main.py: autoflake, isort, black, flake8 pass.

Types of changes

Documentation-only change to the CLI help text; none of the three boxes below apply.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

AI Usage Disclosure

  • 🟥 AI-vibecoded
  • 🟠 AI-generated
  • ⭐ AI-assisted
  • ♻️ No AI used

The docstring wording, the test and this description were drafted with an AI assistant. I reviewed the diff, ran the command and the tests myself, and can explain the change: Typer renders the command docstring as the long help text, and the -- delegation to run_and_monitor() was already implemented in monitor() — only the text was missing.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/how-to/contributing.md document.
  • I have added tests to cover my changes.
  • All new and existing tests in tests/cli passed.

@PRINCE2-AI
PRINCE2-AI requested a review from a team as a code owner October 31, 2026 16:56
Copilot AI balanced review requested due to automatic review settings October 31, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@benoit-cty

Copy link
Copy Markdown
Contributor

Thanks, that was quick!

@benoit-cty
benoit-cty enabled auto-merge October 31, 2026 17:54
@benoit-cty
benoit-cty merged commit 5c259a2 into mlco2:master Oct 31, 2026
13 checks passed
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (e159a68) to head (bd69524).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1472   +/-   ##
=======================================
  Coverage   93.66%   93.66%           
=======================================
  Files          50       50           
  Lines        5591     5591           
=======================================
  Hits         5237     5237           
  Misses        354      354           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PRINCE2-AI

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review and merge, Benoît! Glad the help text is now where users actually look first.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a doc in the CLI to explain how to run a process

3 participants