0.0.5 ā€¢ Published 3 years ago

slapdash-commands v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

šŸ’» Slapdash Commands

Contributors Forks Stargazers Issues MIT License

Slapdash brings all your apps together in one place to give you new superpowers.

This package makes writing your own Slapdash commands fun and easy.

Highlights

  • Actions
  • Configs
  • Move actions
  • Tokens
  • Views (list, form, and masonry)
  • Response builder
  • Autocomplete
  • Arguments
  • Zero dependencies and lightweight (22 kB)
  • Well-documented

Getting Started

Requirements

Slapdash

To test and run your commands, you should have Slapdash installed.

Installation

Install and use this package as easy as running this command.

npm install slapdash-commands

Usage

This is our recommended directory structure.

.
ā””ā”€ā”€ my-command/
    ā”œā”€ā”€ src/
    ā”‚   ā”œā”€ā”€ pages/
    ā”‚   ā”‚   ā”œā”€ā”€ first.ts
    ā”‚   ā”‚   ā”œā”€ā”€ second.ts
    ā”‚   ā”‚   ā””ā”€ā”€ third.ts
    ā”‚   ā”œā”€ā”€ args.ts
    ā”‚   ā””ā”€ā”€ command.ts
    ā”œā”€ā”€ package.json
    ā””ā”€ā”€ tsconfig.json

pages

Each move action is called a page here. A move action changes the location of the Command Bar. We recommend you follow this structure to make your code understandable and testable.

args.ts

This is optional, but creating an interface of the command's arguments helps you with linting and auto-completion.

interface Arguments {
  firstArg?: string;
  secondArg?: string;
  // ...
}

command.ts

Start writing your own command from here.

slapdash((args: Arguments) => {
  // Use the pages, from last to first
  if (args.secondArg !== undefined) {
    return thirdPage(args.secondArg);
  } else if (args.firstArg !== undefined) {
    return secondPage(args.firstArg);
  }

  return firstPage();
});

For more examples, please refer to the Documentation.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Donate šŸ™

You can support this project and transfer BTC to this address.

bc1qgwar7xmpsed3qaq0fvf08qxmyvd40t8t9tnaf4

License

Distributed under the MIT License. See MIT license for more information.