File tree 3 files changed +22
-21
lines changed
app/Console/Commands/Irrdb
3 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ class UpdateAsnDb extends UpdateDb
43
43
*
44
44
* @var string
45
45
*/
46
- protected $ signature = 'irrdb:update-asn-db
47
- {customer? : Customer ASN, ID or shortname (in that order). Otherwise all customers.} ' ;
46
+ protected $ signature = 'irrdb:update-asn-db
47
+ {--asn= : Only update the member with this ASN}
48
+ {--id= : Only update the member with this customer ID} ' ;
48
49
49
50
/**
50
51
* The console command description.
@@ -66,7 +67,7 @@ public function handle(): int
66
67
return -99 ;
67
68
}
68
69
69
- $ customers = $ this ->resolveCustomers ();
70
+ $ customers = $ this ->resolveCustomers ( $ this -> options () );
70
71
71
72
foreach ( $ customers as $ c ) {
72
73
try {
Original file line number Diff line number Diff line change @@ -59,32 +59,31 @@ protected function setupChecks(): bool
59
59
*
60
60
* @return mixed
61
61
*/
62
- protected function resolveCustomers (): mixed
62
+ protected function resolveCustomers ( array $ options ): mixed
63
63
{
64
- $ custarg = $ this ->argument ('customer ' );
64
+ if ( $ options [ 'asn ' ] ) {
65
+ $ c = Customer::whereAutsys ( $ options [ 'asn ' ] )->get ();
65
66
66
- // if not customer specific, return all appropriate ones:
67
- if ( ! $ custarg ) {
68
- return Customer:: currentActive ( true )-> get ( );
69
- }
67
+ if ( ! count ( $ c ) ) {
68
+ $ this -> error ( " No customer found with ASN { $ options [ ' asn ' ]}" );
69
+ exit (- 1 );
70
+ }
70
71
71
- // assume ASN first:
72
- if ( is_numeric ( $ custarg ) && count ( ( $ c = Customer::whereAutsys ( $ custarg )->get () ) ) > 0 ) {
73
72
return $ c ;
74
73
}
75
74
76
- // then ID:
77
- if ( is_numeric ( $ custarg ) && ( $ c = Customer::find ( $ custarg ) ) ) {
78
- return [ $ c ];
79
- }
75
+ if ( $ options [ 'id ' ] ) {
76
+ $ c = Customer::whereId ( $ options [ 'id ' ] )->get ();
77
+
78
+ if ( !count ( $ c ) ) {
79
+ $ this ->error ( "No customer found with ID {$ options [ 'id ' ]}" );
80
+ exit (-1 );
81
+ }
80
82
81
- if ( count ( $ c = Customer::whereShortname ( $ custarg )->get () ) > 0 ) {
82
83
return $ c ;
83
84
}
84
85
85
- $ this ->error ( "Could not find a customer matching id/shortname: " . $ custarg );
86
-
87
- exit (-1 );
86
+ return Customer::currentActive ( true )->get ();
88
87
}
89
88
90
89
/**
Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ class UpdatePrefixDb extends UpdateDb
44
44
* @var string
45
45
*/
46
46
protected $ signature = 'irrdb:update-prefix-db
47
- {customer? : Customer ASN, ID or shortname (in that order). Otherwise all customers.} ' ;
47
+ {--asn= : Only update the member with this ASN}
48
+ {--id= : Only update the member with this customer ID} ' ;
48
49
49
50
/**
50
51
* The console command description.
@@ -66,7 +67,7 @@ public function handle(): int
66
67
return -99 ;
67
68
}
68
69
69
- $ customers = $ this ->resolveCustomers ();
70
+ $ customers = $ this ->resolveCustomers ( $ this -> options () );
70
71
71
72
foreach ( $ customers as $ c ) {
72
73
try {
You can’t perform that action at this time.
0 commit comments