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

Add -L/--logo-only option #1468

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add -L/--logo-only option #1468

wants to merge 3 commits into from

Conversation

yabobay
Copy link

@yabobay yabobay commented Nov 14, 2024

Add the ability to print an ASCII art logo without needing a git repository.

I was kinda thinking of somehow baking this into Printer, but Printer wants an Info and the whole point is to not have an Info.

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

I was kinda thinking of somehow baking this into Printer, but Printer wants an Info and the whole point is to not have an Info.

I see 2 ways to go:

  1. Build an empty Info. See the InfoBuilder struct. I think this should be pretty easy.
  2. Make -L an alias of --no-title --disabled-fields project head version created languages authors last-change url commits churn lines-of-code size license --no-color-palette.

Do either of these seem reasonable?

@spenserblack
Copy link
Collaborator

Oh, and before I forget: thanks for your PR! I agree we should have this. It pairs well with neofetch -L.

@yabobay
Copy link
Author

yabobay commented Nov 14, 2024

Thanks! So i tried going with building an empty Info, and i think it would involve having to give bogus options to InfoBuilder.build. They don't get seen by the user, and i think it'd work, but it's kind of inelegant. So maybe Printer::new should accept an Option<Info>? I think it makes more sense than having a check inside build_info, and it keeps the logic of the -L flag inside main with the other early-exit options.

Allow language detection
@spenserblack
Copy link
Collaborator

spenserblack commented Nov 14, 2024

I pushed aba656d to show what I meant. The benefit is that language detection still works, so users aren't forced to specify the language (forcing users to use the -a option with -L isn't great IMO).

The change I pushed isn't complete. It should also

  • Be refactored/reordered to avoid unused calculations.
  • Be formatted.
  • Hide the color palette.

But how do you feel about continuing with this?

@yabobay
Copy link
Author

yabobay commented Nov 14, 2024

Well, this is gonna sound real dumb, but i was intending this to work totally outside of git repos. So for example i could've had a script show me a random programming language each time i open a shell. And yeah i can still pass the -a flag but that needs a repo and has some amount of startup time cost. Detecting from the repo is probably the more common sense version of this functionality and what most people want, but maybe we could have both?

I could try and make it detect if its in a git repo and act accordingly? (And if it's passed the -a flag, it won't search for a git repo even if it's in one.) If it's not in a git repo and isn't passed the -a flag either, i could just make it spit out some error. Should i do that?

@spenserblack
Copy link
Collaborator

spenserblack commented Nov 14, 2024

Got it. Since this tool is so tied to git repos for most of its behavior, I don't know about making it work outside a repo in this case. I'll have to think about that. I could kind of see it automatically skipping all checks if -a and -L are passed together as an edge-case optimization.

However, have you considered using the onefetch-ascii crate? You could write a small executable that uses that library to print a logo. You could read from our YAML file to populate a list and default colors. Then you can follow pretty much any logic you want for picking a logo (e.g. randomization).

I'd be curious to learn more about your use-case.

@yabobay
Copy link
Author

yabobay commented Nov 15, 2024

Will probably do that then! And my usecase is basically just "i like looking at pretty colors"

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.

2 participants