Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nu-ansi-term instead of ansi_term #2511

Merged
merged 1 commit into from
Mar 24, 2023
Merged

Conversation

nickelc
Copy link
Contributor

@nickelc nickelc commented Mar 23, 2023

The nu-ansi-term crate is a fork of ansi_term which is maintained by the Nushell project.

Highlights:

  • Added "bright" colors ansi 90-97 (foreground) and 100-107 (background).
  • Replaced winapi dependency with windows-sys.

See CHANGELOG.md for the changes since forking it.

Copy link
Collaborator

@Enselic Enselic left a comment

Choose a reason for hiding this comment

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

ansi_term is considered abandoned, so this is a good change, so thank you.

Had some comments.

Cargo.toml Outdated
@@ -42,7 +42,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine

[dependencies]
atty = { version = "0.2.14", optional = true }
ansi_term = "^0.12.1"
ansi_term = { version = "0.47", package = "nu-ansi-term" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -14,7 +14,7 @@ use std::io::{BufReader, Write};
use std::path::Path;
use std::process;

use ansi_term::Colour::Green;
use ansi_term::Color::Green;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool trick that you can keep the old crate name. I didn't know about it.

But long-term I think it will be confusing, so I would prefer if you didn't keep ansi_term around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I went for the minimal changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done and all green.

The `nu-ansi-term` crate is a fork of `ansi_term` which is maintained by
the Nushell project.
@sharkdp
Copy link
Owner

sharkdp commented Mar 24, 2023

@nickelc All of these maintenance PRs of yours are very much appreciated! I really like that they come in small, well-structured individual changesets!

This change looks good to me. Do we "leak" any of these ansi_term/nu_ansi_term types to the public API? In other words: is this a breaking change for bat-as-a-library?

@Enselic has a nice tool to check for this: https://github.com/Enselic/cargo-public-api

@nickelc
Copy link
Contributor Author

nickelc commented Mar 24, 2023

Here is the output of cargo public-api diff 0.22.1 for this branch.

Details

bat on  nu-ansi-term
$ cargo public-api diff 0.22.1

Removed items from the public API
=================================
-pub fn bat::PagingMode::default() -> Self

Changed items in the public API
===============================
(none)

Added items to the public API
=============================
+pub bat::config::Config::nonprintable_notation: bat::NonprintableNotation
+pub fn bat::style::StyleComponents::clear(&mut self)
+pub fn bat::style::StyleComponents::insert(&mut self, component: bat::style::StyleComponent)
+#[non_exhaustive] pub enum bat::NonprintableNotation
+pub bat::NonprintableNotation::Caret
+pub bat::NonprintableNotation::Unicode
+impl core::clone::Clone for bat::NonprintableNotation
+pub fn bat::NonprintableNotation::clone(&self) -> bat::NonprintableNotation
+impl core::cmp::Eq for bat::NonprintableNotation
+impl core::cmp::PartialEq<bat::NonprintableNotation> for bat::NonprintableNotation
+pub fn bat::NonprintableNotation::eq(&self, other: &bat::NonprintableNotation) -> bool
+impl core::default::Default for bat::NonprintableNotation
+pub fn bat::NonprintableNotation::default() -> bat::NonprintableNotation
+impl core::fmt::Debug for bat::NonprintableNotation
+pub fn bat::NonprintableNotation::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
+impl core::marker::Copy for bat::NonprintableNotation
+impl core::marker::StructuralEq for bat::NonprintableNotation
+impl core::marker::StructuralPartialEq for bat::NonprintableNotation
+impl core::marker::Send for bat::NonprintableNotation
+impl core::marker::Sync for bat::NonprintableNotation
+impl core::marker::Unpin for bat::NonprintableNotation
+impl core::panic::unwind_safe::RefUnwindSafe for bat::NonprintableNotation
+impl core::panic::unwind_safe::UnwindSafe for bat::NonprintableNotation
+impl<Q, K> indexmap::equivalent::Equivalent<K> for bat::NonprintableNotation where Q: core::cmp::Eq + core::marker::Sized, K: core::borrow::Borrow<Q> + core::marker::Sized
+pub fn bat::NonprintableNotation::equivalent(&self, key: &K) -> bool
+impl<T, U> core::convert::Into<U> for bat::NonprintableNotation where U: core::convert::From<T>
+pub fn bat::NonprintableNotation::into(self) -> U
+impl<T, U> core::convert::TryFrom<U> for bat::NonprintableNotation where U: core::convert::Into<T>
+pub type bat::NonprintableNotation::Error = core::convert::Infallible
+pub fn bat::NonprintableNotation::try_from(value: U) -> core::result::Result<T, <T as core::convert::TryFrom<U>>::Error>
+impl<T, U> core::convert::TryInto<U> for bat::NonprintableNotation where U: core::convert::TryFrom<T>
+pub type bat::NonprintableNotation::Error = <U as core::convert::TryFrom<T>>::Error
+pub fn bat::NonprintableNotation::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
+impl<T> alloc::borrow::ToOwned for bat::NonprintableNotation where T: core::clone::Clone
+pub type bat::NonprintableNotation::Owned = T
+pub fn bat::NonprintableNotation::clone_into(&self, target: &mut T)
+pub fn bat::NonprintableNotation::to_owned(&self) -> T
+impl<T> core::any::Any for bat::NonprintableNotation where T: 'static + core::marker::Sized
+pub fn bat::NonprintableNotation::type_id(&self) -> core::any::TypeId
+impl<T> core::borrow::Borrow<T> for bat::NonprintableNotation where T: core::marker::Sized
+pub fn bat::NonprintableNotation::borrow(&self) -> &T
+impl<T> core::borrow::BorrowMut<T> for bat::NonprintableNotation where T: core::marker::Sized
+pub fn bat::NonprintableNotation::borrow_mut(&mut self) -> &mut T
+impl<T> core::convert::From<T> for bat::NonprintableNotation
+pub fn bat::NonprintableNotation::from(t: T) -> T
+pub fn bat::PagingMode::default() -> bat::PagingMode

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you

@sharkdp sharkdp merged commit 4d9aaec into sharkdp:master Mar 24, 2023
@nickelc nickelc deleted the nu-ansi-term branch March 24, 2023 21:07
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.

3 participants