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

Offer of help #682

Closed
willmcgugan opened this issue Jul 17, 2020 · 10 comments
Closed

Offer of help #682

willmcgugan opened this issue Jul 17, 2020 · 10 comments

Comments

@willmcgugan
Copy link

Not an issue per se. I noticed you guys are using Rich to do some interesting stuff. I'm the author or Rich, and I just wanted to say feel free to mention me if you ever need any assistance with it.

@ewels
Copy link
Member

ewels commented Jul 17, 2020

Brilliant - thank you very much @willmcgugan, much appreciated!

I've been really enjoying myself over the past few days playing with Rich. We're doing a week long hackathon for @nf-core (see https://nf-co.re/events/2020/hackathon-july-2020) so I've been on a mission to start using Rich throughout the code base since I found out about it! It's a beautiful library - both in terms of code and output 🤩

We only have a couple of instances of click.style left, that we were previously using for coloured output. They are all within click.confirm functions, eg:

tools/nf_core/launch.py

Lines 117 to 121 in bf950c9

if click.confirm(
click.style("Do you want to overwrite this file? ", fg="yellow") + click.style("[y/N]", fg="red"),
default=False,
show_default=False,
):

I saw that Rich has an input method which I want to have a play with soon. I was curious to know if there is a way to handle confirmation prompts with Rich as well? I didn't post an issue yet as I haven't really looked around or tried anything yet, but as you're here maybe you have a suggestion.. 😄

@willmcgugan
Copy link
Author

I've been really enjoying myself over the past few days playing with Rich. We're doing a week long hackathon for @nf-core (see https://nf-co.re/events/2020/hackathon-july-2020) so I've been on a mission to start using Rich throughout the code base since I found out about it! It's a beautiful library - both in terms of code and output 🤩

Glad its working for you! The hackathon explains why you've been so busy.

I think click.prompt does a little more processing of the return value, whereas Console.input just returns a string. I'll think about adding that at some point, in the meantime something like this should work:

if console.input("[yellow]Do you want to overwrite this file?[/] [red][[y/N]]").lower() == "y":
    overwrite() 

@ewels
Copy link
Member

ewels commented Jul 19, 2020

Sounds like solid advice, thanks 👍🏻

Is the [/] needed in your above example? I wasn't sure whether to put those in or not when using multiple colours in a string.

@willmcgugan
Copy link
Author

For this example, you don't strictly need the closing tag. Since the red foreground replaces the yellow foreground. But other styles can overlap. For instance if the first part of the the text was "bold yellow" you might need to close it, or the [y/N] would also be bold.

@willmcgugan
Copy link
Author

You might want to try out the prompt branch which has a new rich.prompt module.

No docs as yet, but see prompt.py for examples.

I'll release this in a day or two when I've got docs. Let me know if you have any feedback.

@ewels
Copy link
Member

ewels commented Jul 21, 2020

Amazing! Thank you - I'll give it a try asap.

@ewels
Copy link
Member

ewels commented Jul 21, 2020

Ok, now I'm going to get really cheeky whilst I have your ear. Feel free to tell me that this is way out of scope and I'll move on 😅

We have a new command-line wizard feature which I wrote using the PyInquirer package. It generally works well (see a demo on YouTube from last week), but PyInquirer seems to have some problems with package management and I need to strip it out (#641).

I'm currently working on alternatives now, such as the much simpler pick for select lists. Any thoughts whether Rich could support any functionality like this? We actually looked for and found Rich in the first place to render the markdown help above these questions. It would be super cool if we could just render the whole console interface through Rich...

@willmcgugan
Copy link
Author

TBH I've been thinking about this for a while. I've seen pyInquirer and similar console packages in other languages, and I would love to implement something similar using Rich to do the rendering.

If it happens, it would probably be an external package, perhaps "rich-interactive", to keep dependancies down for those who don't need it.

Reason it might not happen is my wife says I spend too much time working and not getting paid for it, and she's right. It would be easier to justify if I get Github sponsorship.

@ewels
Copy link
Member

ewels commented Jul 22, 2020

That would be awesome! I've just pinned PyInquirer with a couple of workarounds which should keep things ticking for a bit, but if a Rich package ever turns up I'd love to give it a go (we don't use 90% of the PyInquirer features).

Reason it might not happen is my wife says I spend too much time working and not getting paid for it, and she's right. It would be easier to justify if I get GitHub sponsorship.

A very valid reason! I totally understand. I struggle with this a bit as we are primarily academic and government / grant funded (so a lot of bureaucracy) and also open source / largely volunteer driven. I'll have a think about whether we can compile a list of "upstream developers" or something though, to present to people using our tools. Probably won't amount to much but can't hurt.. 🤔 Made an issue: nf-core/website#448

@willmcgugan
Copy link
Author

I've pushed Rich 3.4.0, with rich.prompt.

ewels added a commit to ewels/nf-core-tools that referenced this issue Jul 23, 2020
@ewels ewels closed this as completed Nov 6, 2020
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

No branches or pull requests

2 participants