Skip to content

feat: add format option to note prompt#284

Merged
43081j merged 2 commits intomainfrom
formatter-note
Apr 12, 2025
Merged

feat: add format option to note prompt#284
43081j merged 2 commits intomainfrom
formatter-note

Conversation

@43081j
Copy link
Copy Markdown
Collaborator

@43081j 43081j commented Apr 11, 2025

This adds a new format option for formatting lines in a note.

For example:

// make all lines cyan
note('message', 'title', {
  format(str) {
    return colors.cyan(str);
  }
});

// don't colour lines at all
note('message', 'title', {
  format(str) {
    return str;
  }
});

// add extra text to each line
note('message', 'title', {
  format(str) {
    return `more text ${str} more text';
  }
});

cc @AdrianGonz97

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 11, 2025

🦋 Changeset detected

Latest commit: d8bea18

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

This PR includes changesets to release 1 package
Name Type
@clack/prompts 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 11, 2025

@example/basic@example/changesets

npm i https://pkg.pr.new/bombshell-dev/clack/@clack/core@284
npm i https://pkg.pr.new/bombshell-dev/clack/@clack/prompts@284

commit: d8bea18

This adds a new `formatter` option for formatting lines in a note.

For example:

``ts
// make all lines cyan
note('message', 'title', {
  formatter(str) {
    return colors.cyan(str);
  }
});

// don't colour lines at all
note('message', 'title', {
  formatter(str) {
    return str;
  }
});

// add extra text to each line
note('message', 'title', {
  formatter(str) {
    return `more text ${str} more text';
  }
});
```
@manuel3108
Copy link
Copy Markdown

This works perfectly!

@AdrianGonz97
Copy link
Copy Markdown

This is really excellent @43081j, thank you!! Being able to further enhance the text by line is also very a nice touch 😄

One small nit: it might be better to just call it format since it's performing an action and would follow the existing pattern of option names. the equivalent being the validate option for prompts (i.e. it's validate instead of validator)

Copy link
Copy Markdown
Member

@dreyfus92 dreyfus92 left a comment

Choose a reason for hiding this comment

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

just a nit 🫡

@43081j
Copy link
Copy Markdown
Collaborator Author

43081j commented Apr 12, 2025

makes sense

have done both changes

@43081j 43081j changed the title feat: add formatter option to note prompt feat: add format option to note prompt Apr 12, 2025
Copy link
Copy Markdown
Member

@dreyfus92 dreyfus92 left a comment

Choose a reason for hiding this comment

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

thank you @43081j 🫡

@43081j 43081j merged commit 99c3530 into main Apr 12, 2025
6 checks passed
@43081j 43081j deleted the formatter-note branch April 12, 2025 15:05
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.

4 participants