@@ -131,47 +131,55 @@ fn main() {
131131 Commands :: Workspaces { command } => match command {
132132 WorkspaceCommands :: List { output } => workspace:: list ( & output) ,
133133 WorkspaceCommands :: Set { workspace_id } => workspace:: set ( workspace_id. as_deref ( ) ) ,
134- _ => eprintln ! ( "not yet implemented" ) ,
135134 } ,
136- Commands :: Connections { workspace_id, command } => {
135+ Commands :: Connections { id , workspace_id, output , command } => {
137136 let workspace_id = resolve_workspace ( workspace_id) ;
138- match command {
139- ConnectionsCommands :: New => connections_new:: run ( & workspace_id) ,
140- ConnectionsCommands :: List { output } => {
141- connections:: list ( & workspace_id, & output)
142- }
143- ConnectionsCommands :: Create { command, name, source_type, config, output } => {
144- match command {
145- Some ( ConnectionsCreateCommands :: List { name, output } ) => {
146- match name. as_deref ( ) {
147- Some ( name) => connections:: types_get ( & workspace_id, name, & output) ,
148- None => connections:: types_list ( & workspace_id, & output) ,
137+ if let Some ( id) = id {
138+ connections:: get ( & workspace_id, & id, & output)
139+ } else {
140+ match command {
141+ Some ( ConnectionsCommands :: New ) => connections_new:: run ( & workspace_id) ,
142+ Some ( ConnectionsCommands :: List { output } ) => {
143+ connections:: list ( & workspace_id, & output)
144+ }
145+ Some ( ConnectionsCommands :: Create { command, name, source_type, config, output } ) => {
146+ match command {
147+ Some ( ConnectionsCreateCommands :: List { name, output } ) => {
148+ match name. as_deref ( ) {
149+ Some ( name) => connections:: types_get ( & workspace_id, name, & output) ,
150+ None => connections:: types_list ( & workspace_id, & output) ,
151+ }
149152 }
150- }
151- None => {
152- let missing: Vec < & str > = [
153- name. is_none ( ) . then_some ( "--name" ) ,
154- source_type. is_none ( ) . then_some ( "--type" ) ,
155- config. is_none ( ) . then_some ( "--config" ) ,
156- ] . into_iter ( ) . flatten ( ) . collect ( ) ;
157- if !missing. is_empty ( ) {
158- eprintln ! ( "error: missing required arguments: {}" , missing. join( ", " ) ) ;
159- std:: process:: exit ( 1 ) ;
153+ None => {
154+ let missing: Vec < & str > = [
155+ name. is_none ( ) . then_some ( "--name" ) ,
156+ source_type. is_none ( ) . then_some ( "--type" ) ,
157+ config. is_none ( ) . then_some ( "--config" ) ,
158+ ] . into_iter ( ) . flatten ( ) . collect ( ) ;
159+ if !missing. is_empty ( ) {
160+ eprintln ! ( "error: missing required arguments: {}" , missing. join( ", " ) ) ;
161+ std:: process:: exit ( 1 ) ;
162+ }
163+ connections:: create (
164+ & workspace_id,
165+ & name. unwrap ( ) ,
166+ & source_type. unwrap ( ) ,
167+ & config. unwrap ( ) ,
168+ & output,
169+ )
160170 }
161- connections:: create (
162- & workspace_id,
163- & name. unwrap ( ) ,
164- & source_type. unwrap ( ) ,
165- & config. unwrap ( ) ,
166- & output,
167- )
168171 }
169172 }
173+ Some ( ConnectionsCommands :: Refresh { connection_id } ) => {
174+ connections:: refresh ( & workspace_id, & connection_id)
175+ }
176+ None => {
177+ use clap:: CommandFactory ;
178+ let mut cmd = Cli :: command ( ) ;
179+ cmd. build ( ) ;
180+ cmd. find_subcommand_mut ( "connections" ) . unwrap ( ) . print_help ( ) . unwrap ( ) ;
181+ }
170182 }
171- ConnectionsCommands :: Refresh { connection_id } => {
172- connections:: refresh ( & workspace_id, & connection_id)
173- }
174- _ => eprintln ! ( "not yet implemented" ) ,
175183 }
176184 } ,
177185 Commands :: Tables { command } => match command {
0 commit comments