stackabletech / stackabletech/stackablectl

feat: Implement colored output (with `NO_COLOR` support)

オープン
#145 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Rust
スター
10
フォーク
5
平均マージ
4時間 41分
マージ済み PR(30日)
4

説明

Colours sould only be enabled when the terminal supports them.
For example, when redirecting output or piping to cat, there should be no escape sequences.

I believe there needs to be a condition around the pretty method (or maybe it should be handled by tracing_subscriber::fmt):

https://github.com/stackabletech/stackable-cockpit/blob/fe37d494359d91e32ae309a9f6d382b4a486c5a0/rust/stackablectl/src/main.rs#L31

Examples:

stackablectl --log-level=DEBUG stack list > /tmp/stackablectl.stdout       # plain redirect
stackablectl --log-level=DEBUG stack list | cat > /tmp/stackablectl.stdout # pipe through cat
TERM= stackablectl --log-level=DEBUG stack list > /tmp/stackablectl.stdout # explicitly set TERM to nothing

If I open it in VIM, it looks like this:

image

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

rust/stackablectl/src/main.rs のリンクされた pretty メソッド周辺から始め、tracing_subscriber::fmt が端末の検出を担当すべきかどうかを比較してください。空の TERM を含め、記載された stackablectl コマンドを出力をリダイレクトおよびパイプした状態で実行し、非対話的な出力にエスケープシーケンスが含まれない一方で、サポートされている端末の出力はカラーのままであり、NO_COLOR が尊重されることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
cli
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
50/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。