@h3ravel/musket 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,6 +73,60 @@ Kernel.init(app, {
|
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
## Creating Commands
|
|
77
|
+
|
|
78
|
+
Commands in Musket extend the base `Command` class and define a **signature** and **handle()** method.
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { Command } from '@h3ravel/musket';
|
|
84
|
+
|
|
85
|
+
export default class GreetCommand extends Command {
|
|
86
|
+
protected signature = 'greet {name}';
|
|
87
|
+
protected description = 'Display a personalized greeting.';
|
|
88
|
+
|
|
89
|
+
async handle() {
|
|
90
|
+
const name = this.argument('name');
|
|
91
|
+
|
|
92
|
+
this.info(`Hello, ${name}!`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If your project uses discovery paths (via `discoveryPaths`),
|
|
98
|
+
this command will be automatically registered.
|
|
99
|
+
|
|
100
|
+
Otherwise, you can manually register it in your application:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
class Application {
|
|
104
|
+
registeredCommands = [GreetCommand];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
await Kernel.init(app);
|
|
108
|
+
|
|
109
|
+
// OR
|
|
110
|
+
|
|
111
|
+
await Kernel.init(app, {
|
|
112
|
+
baseCommands: [BuildCommand],
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Running Commands
|
|
117
|
+
|
|
118
|
+
Once your CLI is compiled or built, you can run commands via:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
node dist/cli.js greet Legacy
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Output:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
Hello, Legacy!
|
|
128
|
+
```
|
|
129
|
+
|
|
76
130
|
## Documentation
|
|
77
131
|
|
|
78
132
|
The full musket documentation is available [Here](https://h3ravel.toneflix.net/musket)
|
package/package.json
CHANGED