File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed
Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 1+ import { Command } from 'grind-cli'
2+
3+ import 'App/Models/StateModel'
4+
5+ export class StatesListCommand extends Command {
6+ // Name of the command
7+ name = 'states:list'
8+
9+ // Description of the command to show in help
10+ description = 'List all states in the database'
11+
12+ // Arguments available for this command
13+ arguments = [ 'term?' ]
14+
15+ // Options for this command
16+ options = {
17+ limit : 'Limit the number of states'
18+ }
19+
20+ run ( ) {
21+ const limit = Number . parseInt ( this . option ( 'limit' , 100 ) )
22+ let query = null
23+
24+ if ( this . containsArgument ( 'term' ) ) {
25+ query = StateModel . find ( this . argument ( 'term' ) )
26+ } else {
27+ query = StateModel . query ( )
28+ }
29+
30+ return query . limit ( limit ) . then ( rows => {
31+ for ( const row of rows ) {
32+ this . comment ( row . name )
33+ }
34+ } )
35+ }
36+
37+ }
Original file line number Diff line number Diff line change 1- export function CommandsProvider ( app ) {
2- // app.get('cli').register(
1+ import 'App/Commands/StatesListCommand'
32
4- // )
3+ export function CommandsProvider ( app ) {
4+ app . get ( 'cli' ) . register ( StatesListCommand )
55}
You can’t perform that action at this time.
0 commit comments