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

Allow adding extra lines to separate commands/parameters #69

Closed
apcamargo opened this issue May 16, 2022 · 7 comments
Closed

Allow adding extra lines to separate commands/parameters #69

apcamargo opened this issue May 16, 2022 · 7 comments
Labels
new feature New feature or request style

Comments

@apcamargo
Copy link
Contributor

This one might be niche, not that useful, and (maybe) annoying to implement. I decided to post it here anyway.

I noticed that when I have several commands, the help dialogue looks very busy and difficult to read:

╭─ Modules ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│  download-database          Download the latest version of Genomad's database and save it in the DESTINATION         │
│                             directory.                                                                               │
│  annotate                   Predict the genes in the INPUT file (FASTA format), annotate them using Genomad's        │
│                             markers (located in the DATABASE directory), and write the results to the OUTPUT         │
│                             directory.                                                                               │
│  find-proviruses            Find integrated viruses within the sequences in INPUT file using the Genomad markers     │
│                             (located in the DATABASE directory) and write the results to the OUTPUT directory. This  │
│                             command depends on the data generated by the annotate module.                            │
│  marker-classification      Classify the sequences in the INPUT file (FASTA format) based on the presence of         │
│                             Genomad markers (located in the DATABASE directory) and write the results to the OUTPUT  │
│                             directory. This command depends on the data generated by the annotate module.            │
│  nn-classification          Classify the sequences in the INPUT file (FASTA format) using the Genomad neural         │
│                             network and write the results to the OUTPUT directory.                                   │
│  aggregated-classification  Aggregate the results of the marker-classification and nn-classification modules to      │
│                             classify the sequences in the INPUT file (FASTA format) and write the results to the     │
│                             OUTPUT directory.                                                                        │
│  score-calibration          Performs score calibration of the sequences in the INPUT file (FASTA format) using the   │
│                             batch correction method and write the results to the OUTPUT directory. This module       │
│                             requires that at least one of the classification modules was classified previously       │
│                             (marker-classification, nn-classification, aggregated-classification).                   │
│  summary                    Generates a classification report file for the sequences in the INPUT file (FASTA        │
│                             format) and write it to the OUTPUT directory.                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

If I add an additional line to separate the commands, the dialogue looks much better.

╭─ Modules ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│  download-database          Download the latest version of Genomad's database and save it in the DESTINATION         │
│                             directory.                                                                               │
│                                                                                                                      │
│  annotate                   Predict the genes in the INPUT file (FASTA format), annotate them using Genomad's        │
│                             markers (located in the DATABASE directory), and write the results to the OUTPUT         │
│                             directory.                                                                               │
│                                                                                                                      │
│  find-proviruses            Find integrated viruses within the sequences in INPUT file using the Genomad markers     │
│                             (located in the DATABASE directory) and write the results to the OUTPUT directory. This  │
│                             command depends on the data generated by the annotate module.                            │
│                                                                                                                      │
│  marker-classification      Classify the sequences in the INPUT file (FASTA format) based on the presence of         │
│                             Genomad markers (located in the DATABASE directory) and write the results to the OUTPUT  │
│                             directory. This command depends on the data generated by the annotate module.            │
│                                                                                                                      │
│  nn-classification          Classify the sequences in the INPUT file (FASTA format) using the Genomad neural         │
│                             network and write the results to the OUTPUT directory.                                   │
│                                                                                                                      │
│  aggregated-classification  Aggregate the results of the marker-classification and nn-classification modules to      │
│                             classify the sequences in the INPUT file (FASTA format) and write the results to the     │
│                             OUTPUT directory.                                                                        │
│                                                                                                                      │
│  score-calibration          Performs score calibration of the sequences in the INPUT file (FASTA format) using the   │
│                             batch correction method and write the results to the OUTPUT directory. This module       │
│                             requires that at least one of the classification modules was classified previously       │
│                             (marker-classification, nn-classification, aggregated-classification).                   │
│                                                                                                                      │
│  summary                    Generates a classification report file for the sequences in the INPUT file (FASTA        │
│                             format) and write it to the OUTPUT directory.                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@ewels
Copy link
Owner

ewels commented May 16, 2022

Should be fairly easy to add as an opt-in thing I think 🤔

@ewels
Copy link
Owner

ewels commented May 16, 2022

Could even give a few different options - blank lines but also horizontal rules / table styles or alternating background colours.

@apcamargo
Copy link
Contributor Author

Would be awesome!

@ewels ewels added new feature New feature or request style labels May 16, 2022
@ewels ewels closed this as completed in 50d89b7 May 17, 2022
ewels added a commit that referenced this issue May 17, 2022
@ewels
Copy link
Owner

ewels commented May 17, 2022

ok, I just added this functionality in 50d89b7

The new examples/click/10_table_styles.py script shows it in action. The top options table I tried to base roughly on your request.

Note that it's not exactly the same, as in order to set leading=1 you have to use a table box style. Using a box immediately adds a bunch of additional spacing / padding (even if that box is invisible in our case). I removed as much of it as I can, but it's still more spaced:

table styles example

Hopefully that's ok. If you can figure out how to further reduce the padding, let me know 👍🏻 Alternatively we could add the spacing manually by just dumping a newline in to the help text. More crude, but should have the desired effect.

I figured that people would inevitably request this at custom-group level eventually, so I wrote it in such a way that it can be done on a per-group level too. You can see that in action in examples/click/03_groups_sorting.py

@apcamargo
Copy link
Contributor Author

Looks perfect! I actually enjoy the extra padding, but I can try to figure out a solution that would allow us to control it.

@ewels
Copy link
Owner

ewels commented May 17, 2022

Great! I set it up with padding and pad_edge already (the latter set to False by default, which the best effect):

STYLE_OPTIONS_TABLE_PAD_EDGE = False
STYLE_OPTIONS_TABLE_PADDING = (0, 1)

But I guess that there is still some other cell padding or something creeping in which could be finetuned to get exactly the right effect... But I didn't spend ages looking as I thought it looked ok as it was 😅

Note that some of the table style settings only work when the box is set to something other than None. I probably should have mentioned that in the readme somewhere. That's why I set it to SIMPLE here:

click.rich_click.STYLE_OPTIONS_TABLE_LEADING = 1
click.rich_click.STYLE_OPTIONS_TABLE_BOX = "SIMPLE"

@apcamargo
Copy link
Contributor Author

You're too efficient. I can't keep up hahaha. Thank you so much, @ewels!

I'll try to contribute by figuring out how to fix the other aesthetic bugs that have been bothering me (#35 and #34), but they are much trickier than I was expecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request style
Projects
None yet
Development

No branches or pull requests

2 participants