@@ -95,18 +95,27 @@ protected function determineCloudProvider(string $question, InputInterface $inpu
9595 */
9696 protected function determineNetwork (string $ question , InputInterface $ input , ConsoleOutput $ output ): int
9797 {
98- $ networkIdOrName = $ this ->getStringArgument ($ input , 'network ' );
98+ $ networkIdOrName = null ;
99+
100+ if ($ input ->hasArgument ('network ' )) {
101+ $ networkIdOrName = $ this ->getStringArgument ($ input , 'network ' );
102+ } elseif ($ input ->hasOption ('network ' )) {
103+ $ networkIdOrName = $ this ->getStringOption ($ input , 'network ' );
104+ }
105+
99106 $ networks = $ this ->apiClient ->getTeamNetworks ($ this ->cliConfiguration ->getActiveTeamId ());
100107
101108 if (empty ($ networkIdOrName ) && $ input ->isInteractive ()) {
102109 $ networkIdOrName = $ output ->choiceWithResourceDetails ($ question , $ networks );
110+ } elseif (empty ($ networkIdOrName ) && !$ input ->isInteractive ()) {
111+ throw new RuntimeException ('Must specify a network when running command in non-interactive mode ' );
112+ } elseif (1 < $ networks ->where ('name ' , $ networkIdOrName )->count ()) {
113+ throw new RuntimeException (sprintf ('Unable to select a network because more than one network has the name "%s" ' , $ networkIdOrName ));
103114 }
104115
105116 $ network = $ networks ->firstWhere ('name ' , $ networkIdOrName ) ?? $ networks ->firstWhere ('id ' , $ networkIdOrName );
106117
107- if (1 < $ networks ->where ('name ' , $ networkIdOrName )->count ()) {
108- throw new RuntimeException (sprintf ('Unable to select a network because more than one network has the name "%s" ' , $ networkIdOrName ));
109- } elseif (empty ($ network ['id ' ])) {
118+ if (empty ($ network ['id ' ])) {
110119 throw new RuntimeException (sprintf ('Unable to find a network with "%s" as the ID or name ' , $ networkIdOrName ));
111120 }
112121
0 commit comments