@@ -37,20 +37,34 @@ public function handle(Config $config) : void
3737 $ this ->input ->setArgument ('name ' , 'default ' );
3838 }
3939
40- foreach (['auth ' , 'host ' ] as $ option ) {
41- if (! $ this ->option ($ option )) {
42- $ this ->input ->setOption ($ option , $ this ->ask (sprintf ('ENTER %s ' , strtoupper (
43- $ option
44- ))));
40+ if (! $ this ->option ('auth ' )) {
41+ $ this ->input ->setOption ('auth ' , $ this ->ask ('ENTER AUTH FILE PATH ' ));
42+ }
43+
44+ if (! $ this ->option ('listen ' )) {
45+ $ listen = $ this ->ask ('ENTER LISTEN HOST AND PORT ' , 'localhost:3000 ' );
46+
47+ // Add http:// prefix if no scheme is provided
48+ if (! str_starts_with ($ listen , 'http:// ' ) && ! str_starts_with ($ listen , 'https:// ' )) {
49+ $ listen = 'http:// ' . $ listen ;
4550 }
51+
52+ // Force http:// by replacing https:// if present
53+ $ listen = preg_replace ('/^https:\/\//i ' , 'http:// ' , $ listen );
54+
55+ $ this ->input ->setOption ('listen ' , $ listen );
56+ }
57+
58+ if (! $ this ->option ('redirect ' )) {
59+ $ this ->input ->setOption ('redirect ' , $ this ->ask ('ENTER REDIRECT URI ' , $ this ->option ('listen ' )));
4660 }
4761
4862 $ config ->store ([
49- 'auth ' => $ this ->option ( ' auth ' ),
50- ' host ' => $ this -> option ( ' host ' ),
51- 'name ' => $ this ->argument (
52- ' name '
53- ),
63+ 'name ' => $ this ->argument ( ' name ' ),
64+ //
65+ 'auth ' => $ this ->option ( ' auth ' ),
66+ ' listen ' => $ this -> option ( ' listen ' ),
67+ ' redirect ' => $ this -> option ( ' redirect ' ),
5468 ]);
5569
5670 $ gphoto = new GPhoto ($ this ->argument ('name ' ));
@@ -91,7 +105,8 @@ public function getOptions() : array
91105 {
92106 return [
93107 ['auth ' , null , InputOption::VALUE_REQUIRED , 'Credential file ' ],
94- ['host ' , null , InputOption::VALUE_REQUIRED , 'Authorised redirect URIs ' ],
108+ ['listen ' , null , InputOption::VALUE_REQUIRED , 'Host and port to listen for OAuth callback (e.g., 127.0.0.1:8080) ' ],
109+ ['redirect ' , null , InputOption::VALUE_OPTIONAL , 'Redirect URI (default: uses the listen input value) ' ],
95110 ];
96111 }
97112}
0 commit comments