1.9.3 β€’ Published 8 months ago

@sapphire/cli v1.9.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Sapphire Logo

@sapphire/cli

CLI for Sapphire Framework.

GitHub npm Depfu

Features

  • Written in TypeScript
  • Generate Sapphire projects easily
  • Generate components (commands, listeners, etc.)
  • Create your own templates for components

Usage

$ npm install -g @sapphire/cli
$ sapphire COMMAND
running command...
$ sapphire (-v|--version|version)
@sapphire/cli/0.0.1 linux-x64 node-v16.10.0
$ sapphire --help [COMMAND]
USAGE
  $ sapphire COMMAND
...

Commands

sapphire help [COMMAND]

display help for sapphire

USAGE
  $ sapphire help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

Component Templates

Default component templates are:

  • command
  • listener
  • argument
  • precondition

If you want to make your own templates, or want to override the default ones, read the next section.

Custom component templates

Enable custom component templates

In the .sapphirerc.json file:

  • Set customFileTemplates.enabled to true
  • Set customFileTemplates.location to the name of the directory you want to store your templates in.

Example:

{
	"customFileTemplates": {
		"enabled": true,
		"location": "templates"
	}
}

Create custom component templates

  • Create a file like this in your custom template directory <templateName>.<language>.sapphire (e.g command.ts.sapphire). If you make its name same as one of the default template's, your template will override the default one.
  • Template's have 2 parts, config and the template, separated with ---.
  • We first need to type the config:
{
	"category": "commands"
}

category is the category of that template, CLI uses it to know where to create the component by finding that category's location from the locations field in .sapphirerc.json. You can create your own categories. Default categories are: commands, listeners, arguments, preconditions. This example uses the commands category.

  • Now we add the separator.
{
  "category": "commands"
}
---
  • And the last part, we add the template.
{
  "category": "commands"
}
---
import { ApplyOptions } from '@sapphire/decorators';
import { MyExtendedCommand } from './somewhere';
import { Message } from 'discord.js';

@ApplyOptions<MyExtendedCommand.Options>({
	description: 'A basic command'
})
export class {{name}}Command extends MyExtendedCommand {
	public async run(message: Message) {
		return message.channel.send('Hello world!');
	}
}

If you look at the name of the class, you will see it includes {{name}}, this is the component's name and it is replaced with that name when creating the component. For example: if we created this component with the name HelloWorld, the name of the exported class would be HelloWorldCommand. It is not required but if you need it, this is how it's done.

  • And now you can create component with your template
sapphire generate <templateName> <componentName>

Buy us some doughnuts

Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!

We accept donations through Open Collective, Ko-fi, Paypal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.

Donate WithAddress
Open CollectiveClick Here
Ko-fiClick Here
PatreonClick Here
PayPalClick Here

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

1.9.4-next.92cc59a

8 months ago

1.9.4-next.1274945

8 months ago

1.9.4-next.badf6f3

8 months ago

1.9.4-next.d6576c4

8 months ago

1.9.4-next.89501bc

8 months ago

1.9.4-next.eaef1a1

8 months ago

1.9.4-next.368c576

8 months ago

1.9.4-next.01f33cd

8 months ago

1.9.4-next.94a15e9

9 months ago

1.9.4-next.200abd0

8 months ago

1.9.4-next.2b6e8ab

9 months ago

1.9.4-next.b396523

9 months ago

1.9.4-next.7eaeffd

10 months ago

1.9.4-next.b4e7cd1

10 months ago

1.9.4-next.feb4e53

11 months ago

1.9.4-next.89e9d87

10 months ago

1.9.4-next.84a2d72

12 months ago

1.9.4-next.5e16571

11 months ago

1.9.4-next.25ee503

11 months ago

1.9.4-next.7f92afc

10 months ago

1.9.4-next.c9def17

12 months ago

1.9.4-next.6c368ba

12 months ago

1.9.4-next.4cfc842

12 months ago

1.9.4-next.6db73f9

10 months ago

1.9.4-next.b2bd55c

10 months ago

1.9.4-next.ac49009

11 months ago

1.9.4-next.d692982

10 months ago

1.9.4-next.fb2094d

10 months ago

1.9.4-next.1c61cc1

11 months ago

1.9.4-next.bc8253f

10 months ago

1.9.4-next.8734536

10 months ago

1.9.3

1 year ago

1.9.2

1 year ago

1.9.1

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago