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

feat(@clack/core,@clack/prompts): multiline support #143

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

Conversation

orochaa
Copy link
Contributor

@orochaa orochaa commented Aug 14, 2023

Multiline Support

Support multiline texts either with \n, or long ones that exceed terminal width, without breaking the layout

List of supported prompts:

  • text
  • password
  • confirm
    • Is just yes/no
  • select
  • selectKey
    • It was made to handle short options
  • multiselect
  • groupMultiselect
    • It was made to handle short options
  • note
  • intro
  • cancel
  • outro
  • log
  • spinner

Continuation of #141

Closes #101
Closes #132
Relates #135 #111 #35

@changeset-bot
Copy link

changeset-bot bot commented Aug 14, 2023

🦋 Changeset detected

Latest commit: b780203

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/prompts Minor
@clack/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@orochaa orochaa marked this pull request as draft August 14, 2023 17:19
@orochaa
Copy link
Contributor Author

orochaa commented Aug 14, 2023

@cpreston321 @natemoo-re take a look on this version, this would be my approach to implement multi line support on core

@orochaa
Copy link
Contributor Author

orochaa commented Aug 18, 2023

Hey @cpreston321 @natemoo-re, I created a subpath themes on core, that exports a defaultTheme function and our Symbols that are implemented by prompts, this can be used to create more themes, and it is also helpful for people that wants to extend core with a starting point out of the box. Then I implemented this theme on prompts with our previous alterations.

If you agree with these alterations, we can create a doc on how to create a theme,
then furthermore use these themes as options on promps

I hope you enjoy it!

@orochaa orochaa marked this pull request as ready for review August 18, 2023 22:08
@cpreston321
Copy link
Collaborator

@Mist3rBru I am starting to like this. The only thing is core should have the utility function to create the theme and @clack/prompt should create that theme using that helper. Another option is to create another package called @clack/themes that has different themes and presets that @clack/prompts consume.

I think core should hold core functionality so people can tweak there own. @clack/prompts has it's unique theme.

What do you think? @Mist3rBru

@orochaa
Copy link
Contributor Author

orochaa commented Aug 21, 2023

@cpreston321 my goal with defaultTheme was to somehow prove that it is possible to create a theme with format method.

The only thing is core should have the utility function to create the theme and @clack/prompt should create that theme using that helper.

I think core should hold core functionality so people can tweak there own. @clack/prompts has it's unique theme.

Thinking this way, we will not provide theme options, neither on core or prompts, since people can create their own.

Another option is to create another package called @clack/themes that has different themes and presets that @clack/prompts consume.

That would be the ideal, but since this PR is focused on multiline suport, it should be made on other PR, with more options, to not mix things.

For now we can keep it simple, only moving this theme to prompts, stick with this format method, and track these themes on other PR.

@orochaa
Copy link
Contributor Author

orochaa commented Aug 21, 2023

@cpreston321 changes have been applied, changeset is included. When you are ready, it can be merged.

Thank you very much for your support! I am glad to contribute 😄.

@cpreston321 cpreston321 requested a review from natemoo-re August 24, 2023 20:51
@cpreston321
Copy link
Collaborator

cpreston321 commented Aug 24, 2023

Hey @Mist3rBru! I am still seeing some weirdness with multiline on password. Think you can check it out? Once we fine tune this. I will ping nate for feedback. Then hopefully get this merged in 🙏🏼

Screen.Recording.2023-08-24.at.4.55.36.PM.mov

@orochaa
Copy link
Contributor Author

orochaa commented Aug 24, 2023

@cpreston321 I updated the strLength function to handle these unicode, ansi and color chars, now it must not happen again.

@mazshakibaii
Copy link

This will be a huge improvement! @cpreston321 @natemoo-re - if you could please review and merge it'd be much appreciated.

@steve8708
Copy link

I would hugely value this too 🙋

Copy link

@AntoineKM AntoineKM left a comment

Choose a reason for hiding this comment

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

Seems to be fine, can you check it @natemoo-re please ?

@babakfp babakfp mentioned this pull request Oct 14, 2024
@orochaa orochaa force-pushed the core-multiline branch 3 times, most recently from b0bbe9f to 718b9d5 Compare November 26, 2024 18:39
@orochaa orochaa force-pushed the core-multiline branch 2 times, most recently from f868484 to f9cae47 Compare December 15, 2024 16:29
@a-type
Copy link

a-type commented Jan 10, 2025

Seems like this has been functionally complete for over a year. Just wanted to signal a bit more support for this functionality.

I love using Clack for one-off, low complexity CLIs to automate processes for teams in repos. Particularly for repo setup scripts for onboarding. One step I'd like to be able to include more easily is pasting an externally stored .env secret file into the script to bootstrap monorepo local secret configurations. Presently there's no way to do that without formatting the stored secret as a single line with delimiters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants