generate-command Command
Interface
The command creates a new CLI command file with the following signature:
pinstripe generate-command <name>
Parameters
name(required) - The name of the command to create (converted to snake_case)
Examples
# Create a simple command
pinstripe generate-command my-task
# Create a command with multiple words
pinstripe generate-command send-email
# Create a command with camelCase (will be converted to snake_case)
pinstripe generate-command sendNotification
Description
The generate-command command is a CLI scaffolding tool that creates new command files in your Pinstripe application. It automatically:
- Normalizes naming - Converts the file name to snake_case format
- Creates command file - Generates a new command in
lib/commands/directory - Sets up file importer - Creates
_file_importer.jsif it doesn't exist - Provides starter code - Includes basic command structure with placeholder implementation
Generated Files
lib/commands/
├── _file_importer.js # Command base class import (created if needed)
└── command_name.js # Your new command file
Generated Command Structure
Each generated command includes:
export default {
run(){
console.log('command-name command coming soon!')
}
};
Usage in Application
After generating a command, you can:
-
Run the command via CLI:
pinstripe command-name -
Customize the implementation by editing the
run()method -
Add metadata using the
meta()method for parameters and descriptions -
Access Pinstripe features like database, services, and utilities
Command Development
Adding Parameters
export default {
meta(){
this.hasParam('email', { type: 'string', description: 'User email address' });
this.hasParam('force', { type: 'boolean', description: 'Force operation' });
},
run(){
const email = this.params.email;
const force = this.params.force;
// Implementation here
}
};
Using Services
export default {
run(){
const userService = this.services.user;
// Use services here
}
};
Related Commands
list-commands- List all available commands in the projectgenerate-service- Generate business logic servicesgenerate-background-job- Generate scheduled tasks