bombshell-dev / clack

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

feat(@clack/core,@clack/prompts): improve types event emitter & global aliases #147

Open cpreston321 opened 1 year ago

cpreston321 commented 1 year ago

Resolves: #125 - without changing core default functionality.

In this PR I enhance core types for event emitter while also adding setGlobalAliases. This function while be able to map global aliases for ['up', 'down', 'left', 'right', 'space', 'enter', 'cancel'] default keys. You can also map these keys as a sequence char or the actually char name. Example.

p.setGlobalAliases([
    ['w', 'up'],
    ['s', 'down'],
    ['a', 'left'],
    ['d', 'right'],
    ['escape', 'cancel'],
    ['\x03', 'cancel'], // Crtl+C example from default aliases.
]);
changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 8dc022154907c54d1b03df95a99593ebeb8f3994

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 | Patch | | @clack/core | Patch |

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

cpreston321 commented 1 year ago

@Mist3rBru can you take a look at this ?

Mist3rBru commented 1 year ago

@cpreston321 great job! You nailed it.