Skip to content

Conversation

@BlackAsLight
Copy link
Contributor

@BlackAsLight BlackAsLight commented Jul 9, 2025

Read (#6755) for an overview.

There are many static methods and properties here. This is not an exhaustive list of what is available. Nor is everything guaranteed to work in every terminal. But I have tested each one and they all work in my terminal.

This example creates a very big "Hello World!" in terminals that support these Ansi codes.

import * as Ansi from "@std/cli/unstable_ansi";

console.log(
  Ansi.doubleHeightTop +
  "Hello World!\n" +
  Ansi.doubleHeightBottom + 
  "Hello World!",
);

No tests as of yet have been written for this module as I am not sure how to write unit tests to test its behaviour. The codes are either correct or incorrect and whether they work in the terminal is dependent on whether the terminal supports said code.

@codecov
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.15%. Comparing base (eccdeff) to head (5c2ba4a).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6756   +/-   ##
=======================================
  Coverage   94.15%   94.15%           
=======================================
  Files         587      587           
  Lines       42468    42468           
  Branches     6702     6702           
=======================================
  Hits        39986    39986           
  Misses       2433     2433           
  Partials       49       49           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

IMHO, this should be implemented as pure functions and constants, rather than a class. We've also stepped away from using enums in this codebase.

@kt3k
Copy link
Member

kt3k commented Jul 10, 2025

I agree with @iuioiua . Class usage like this seems strange to me.

@timreichen
Copy link
Contributor

IMHO, this should be implemented as pure functions and constants, rather than a class. We've also stepped away from using enums in this codebase.

I remember a meeting when it was decided to have classes only in std when they have a changeable state (I think it was a discussion about CSV functions vs static class like JSON.
).
import * as Ansi from "..." will group exports together and works similar to an utility class, except functions are tree-shakable and can also be imported separately if needed.

@BlackAsLight
Copy link
Contributor Author

BlackAsLight commented Jul 10, 2025

22 of the 43 codes would just be exporting constant variables.

To add to the enum bit. It is a const enum so it disappears when the code is transpiled. The numbers behind the enum is what's important for the code and using a const enum to represent each number adds to readability.

@BlackAsLight BlackAsLight changed the title feat(cli): Introduce Ansi class feat(cli): Introduce Ansi module Jul 11, 2025
@CLAassistant
Copy link

CLAassistant commented Jul 11, 2025

CLA assistant check
All committers have signed the CLA.

@BlackAsLight
Copy link
Contributor Author

I am never attempting a rebase again

@kt3k kt3k changed the title feat(cli): Introduce Ansi module feat(cli/unstable): Introduce Ansi module Jul 17, 2025
@kt3k
Copy link
Member

kt3k commented Jul 17, 2025

Mostly looks good to me. Left some question

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@iuioiua What do you think?

@BlackAsLight BlackAsLight requested a review from iuioiua July 17, 2025 10:11
@kt3k
Copy link
Member

kt3k commented Jul 22, 2025

Let's try and iterate

@kt3k kt3k merged commit 28633cf into denoland:main Jul 22, 2025
19 checks passed
@BlackAsLight BlackAsLight deleted the ansi branch July 22, 2025 02:44
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.

5 participants