-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
bat as a library #423
Comments
Thank you for the feedback. I am not planning to do that. I'm also not sure if the resulting library would really be a useful library as it mixes together too many things, in my opinion. There is syntax highlighting, git modifications, lots of direct I/O operations, line numbering, different styles, themes, caching-logic, customization-logic, integration with the pager, wrapping, etc. etc. If we want to build a useful library with a clean API out of this, we would have to separate it into many pieces and you would probably be left with something like |
Yeah I'm using Alternatively, an output-agnostic pretty-printer on top of |
Just whipped up a quick crate for that. Say hi to prettyprint 👋 . I don't expect much resonance from that, as I mostly need it for License is the same as for So, I guess we can close this issue. 😊 |
It will be a bit complicated to stay up to date with what is happening in I can now see that you really want most of
Thank you! The attribution looks good. To be formally compliant with the open source licences, I think you would have to add a copy of |
In guess the easiest way would be to use The caveat is, that I changed most &str types to String types along the way, because that was quicker to get working ownership-wise, so we might have to change that back.
Actually, there is. 😉
I've added your copyright header as well. 👍 I've added the copyright notice |
I'm sorry, but that's not a very attractive option for me. This would complicate working on
Oh great, thank you very much! |
@sharkdp if you wanted to move most of bat into a library you could:
then cargo publish will probably do the right thing and |
I would also love this to be available as a library. I tried |
@quodlibetor Thank you very much for your suggestions! @mitsuhiko Thank you for the feedback. I think I have changed my mind (with respect to my first comment here). I'm happy to support splitting Just to be sure, I'd like to list a few things that I would require (read: I would need to hear very good reasons if we want to break with one of these) if we go forward with this:
Concerning the "release process" part: If I understand @quodlibetor correctly, there will be just one (public) crate called |
Not quite: there would just be one git repository https://github.com/sharkdp/bat but the directory structure would include:
libbat would be independently versionable, and the dependencies list in the I don't recall what the release procedure becomes -- it might be just |
I don't think splitting into a separate repo is necessary.
There would be two crates but version in lockstep out of the same repo. I have typically a small script I run to help make the release (bumps the versions in the cargo toml). I will make a fork and send a PR with some initial work for this. |
Also it can be done less invasive than @quodlibetor suggests in terms of directory layout. I will try to approaches. |
Oh I'm excited to see that. |
I started an initial attempt in #469. There is a bit of work needed to reshape things into a library (batwing) and the CLI (bat) but it seems pretty simple. The main things I ran into so far:
@mre maybe you want to have a look at if what I did here makes any sense since you already attempted something similar for |
Just wanted to +1 how great this feature would be. I just released mnemonic, which relies on pretyprint to print simple notes files to the terminal—and it would be great to be able to rely on batwing directly. Thanks for changing your mind about implementing batwing (and, as others have said, great name!) |
One additional reason why I think the librarification is amazing: this enables people to build CLI applications with visual cohesion, as the same coloring logic can be used across various tools. Additionally, all of those other programs can get theming support for free - and the themes will be consistent! |
edit: kind of overwhelmed between day job and contract right now unfortunately |
Re-opening this, as there are a few more to-do's. See #693 |
Moving the to do list here:
|
Please see the v0.13 release notes for further instructions: https://github.com/sharkdp/bat/releases/tag/v0.13.0 |
Hey folks, I remember there was an issue to create a custom PAGER. Check out https://github.com/noborus/ov |
Recently I needed a way to pretty-print some Rust code to the command-line while building cargo-inspect.
I used syntect, but in a very crude way. It occured to me, that by using
bat
as a pretty-printer, I could piggy-back on what already exists and get features like line-numbers for free.Probably other projects would want to do the same.
So I wonder if you considered providing a
lib.rs
, which would allow for using this crate as a library.The
main.rs
, would then simply use thelib.rs
as a dependency. That seems to be quite a common pattern. As an additional advantage, it would decouple the argument parsing from the rest of the code. Would that be possible?The text was updated successfully, but these errors were encountered: