HexdocsMcp.CLI.Progress (HexDocs MCP v0.6.0)
View SourceUtilities for displaying progress indicators in command-line interfaces.
Summary
Functions
Displays a progress bar for a given total count.
Displays a message, executes a function, and updates the message upon completion.
Creates a single-line workflow with animated spinner and checkmarks.
Functions
Displays a progress bar for a given total count.
Returns a function that should be called with the current count.
Examples
progress = HexdocsMcp.CLI.Progress.progress_bar("Copying files", 100)
Enum.each(1..100, fn i ->
:timer.sleep(50) # Do some work
progress.(i)
end)
Displays a message, executes a function, and updates the message upon completion.
Options
:success_message
- Text appended after the original message on success (default: "[✓]"):failure_message
- Text appended after the original message on failure (default: "[✗]")
Examples
HexdocsMcp.CLI.Progress.with_spinner("Processing files", fn ->
:timer.sleep(2000)
{:ok, "Done!"}
end)
# Output initially: Processing files...
# Output finally: Processing files [✓]
HexdocsMcp.CLI.Progress.with_spinner("Downloading", fn ->
:timer.sleep(1000)
raise "Network Error"
end, failure_message: "[Failed]")
# Output initially: Downloading...
# Output finally: Downloading [Failed]
Creates a single-line workflow with animated spinner and checkmarks.
Returns a tuple of two functions:
- start_stage(stage_name) - Start a new stage with animated spinner
- complete_workflow() - Complete the workflow with final checkmark
Example
{next_stage, complete} = HexdocsMcp.CLI.Progress.workflow(["Fetching", "Converting", "Processing"])
next_stage.("Fetching")
# do fetching work...
next_stage.("Converting")
# do conversion work...
next_stage.("Processing")
# do processing work...
complete.()