bombshell-dev / clack

Effortlessly build beautiful command-line apps
https://clack.cc
5.25k stars 88 forks source link

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

Open Mist3rBru opened 10 months ago

Mist3rBru commented 10 months ago

Multiline Support

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

List of supported prompts:

Continuation of #141

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

changeset-bot[bot] commented 10 months ago

🦋 Changeset detected

Latest commit: 5d3030b9d9c1daf87d875819ad1bb0c2f4fbc5d4

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

Mist3rBru commented 10 months ago

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

Mist3rBru commented 10 months ago

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!

cpreston321 commented 10 months ago

@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

Mist3rBru commented 10 months ago

@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.

Mist3rBru commented 10 months ago

@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 commented 10 months ago

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 🙏🏼

https://github.com/natemoo-re/clack/assets/6619884/98f8bb76-802c-49fd-b69a-7455384d0243

Mist3rBru commented 10 months ago

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

mazshakibaii commented 9 months ago

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

steve8708 commented 1 month ago

I would hugely value this too 🙋