1414class ReadCommand extends Command
1515{
1616 protected $ signature = 'read '
17- . ' {repository?* : Full or partial repository names} '
18- . ' {--i|except-issues : Exclude issues from processing} '
19- . ' {--p|except-pulls : Exclude Pull Requests from processing} '
20- . ' {--m|except-mentions : Exclude notifications with your mention from processing} '
21- . ' {--o|with-open : Process including open Issues and Pull Requests} '
22- . ' {--token= : Specifies the token to use} ' ;
17+ . ' {repository?* : Full or partial repository names} '
18+ . ' {--r|except-repository=* : Exclude repositories from processing} '
19+ . ' {--i|except-issues : Exclude issues from processing} '
20+ . ' {--p|except-pulls : Exclude Pull Requests from processing} '
21+ . ' {--m|except-mentions : Exclude notifications with your mention from processing} '
22+ . ' {--o|with-open : Process including open Issues and Pull Requests} '
23+ . ' {--token= : Specifies the token to use} ' ;
2324
2425 protected $ description = 'Marks as read all notifications based on specified conditions ' ;
2526
2627 public function handle (): void
2728 {
28- $ repositories = $ this ->repositories ();
29+ $ include = $ this ->repositories ();
30+ $ except = $ this ->exceptRepositories ();
2931
30- $ this ->welcome ($ repositories );
32+ $ this ->welcome ($ include , $ except );
3133
3234 if ($ this ->hasContinue ()) {
33- $ this ->read ($ repositories );
35+ $ this ->read ($ include );
3436 }
3537 }
3638
37- protected function welcome (array $ repositories ): void
39+ protected function welcome (array $ repositories, ? array $ exceptRepositories ): void
3840 {
3941 if ($ repositories ) {
40- Output::info ('You specified the following repository name masks: ' );
41-
42- $ this ->components ->bulletList ($ repositories );
42+ $ this ->bulletList ('You specified the following repository name masks: ' , $ repositories );
43+ }
4344
44- return ;
45+ if ($ exceptRepositories ) {
46+ $ this ->bulletList ('You specified the following masks to exclude repositories: ' , $ exceptRepositories );
4547 }
4648
47- Output::info ('Mark as read all notifications except open ones ' );
49+ if (!$ repositories && !$ exceptRepositories ) {
50+ Output::info ('Mark as read all notifications except open ones ' );
51+ }
4852 }
4953
5054 protected function hasContinue (): bool
@@ -56,6 +60,7 @@ protected function read(array $repositories): void
5660 {
5761 $ this ->gitHub ()
5862 ->repositories ($ repositories )
63+ ->exceptRepositories ($ this ->exceptRepositories ())
5964 ->exceptIssues ($ this ->exceptIssues ())
6065 ->exceptPulls ($ this ->exceptPulls ())
6166 ->exceptMentions ($ this ->exceptMentions ())
@@ -70,9 +75,10 @@ protected function read(array $repositories): void
7075 protected function shouldBeAll (array $ repositories ): bool
7176 {
7277 return empty ($ repositories )
73- && ! $ this ->exceptIssues ()
74- && ! $ this ->exceptPulls ()
75- && ! $ this ->exceptMentions ()
78+ && !$ this ->exceptRepositories ()
79+ && !$ this ->exceptIssues ()
80+ && !$ this ->exceptPulls ()
81+ && !$ this ->exceptMentions ()
7682 && $ this ->withOpen ();
7783 }
7884
@@ -81,19 +87,20 @@ protected function gitHub(): GitHub
8187 $ client = ClientFactory::make ($ this ->token ());
8288
8389 return app (GitHub::class, [
84- 'output ' => $ this ->components ,
85- 'github ' => $ client ,
90+ 'output ' => $ this ->components ,
91+ 'github ' => $ client ,
8692 'paginator ' => new ResultPager ($ client ),
8793 ]);
8894 }
8995
9096 protected function repositories (): array
9197 {
92- return collect ($ this ->argument ('repository ' ))
93- ->filter ()
94- ->unique ()
95- ->sort ()
96- ->all ();
98+ return $ this ->argument ('repository ' );
99+ }
100+
101+ protected function exceptRepositories (): ?array
102+ {
103+ return array_filter ($ this ->option ('except-repository ' )) ?: null ;
97104 }
98105
99106 protected function exceptIssues (): bool
@@ -116,6 +123,22 @@ protected function withOpen(): bool
116123 return $ this ->option ('with-open ' );
117124 }
118125
126+ protected function bulletList (string $ title , array $ values ): void
127+ {
128+ Output::info ($ title );
129+
130+ $ this ->components ->bulletList ($ this ->sort ($ values ));
131+ }
132+
133+ protected function sort (array $ values ): array
134+ {
135+ return collect ($ values )
136+ ->filter ()
137+ ->unique ()
138+ ->sort ()
139+ ->all ();
140+ }
141+
119142 protected function token (): string
120143 {
121144 if ($ token = $ this ->detectToken ()) {
0 commit comments