@@ -116,47 +116,55 @@ fn main() {
116116 Commands :: Workspaces { command } => match command {
117117 WorkspaceCommands :: List { output } => workspace:: list ( & output) ,
118118 WorkspaceCommands :: Set { workspace_id } => workspace:: set ( workspace_id. as_deref ( ) ) ,
119- _ => eprintln ! ( "not yet implemented" ) ,
120119 } ,
121- Commands :: Connections { workspace_id, command } => {
120+ Commands :: Connections { id , workspace_id, output , command } => {
122121 let workspace_id = resolve_workspace ( workspace_id) ;
123- match command {
124- ConnectionsCommands :: New => connections_new:: run ( & workspace_id) ,
125- ConnectionsCommands :: List { output } => {
126- connections:: list ( & workspace_id, & output)
127- }
128- ConnectionsCommands :: Create { command, name, source_type, config, output } => {
129- match command {
130- Some ( ConnectionsCreateCommands :: List { name, output } ) => {
131- match name. as_deref ( ) {
132- Some ( name) => connections:: types_get ( & workspace_id, name, & output) ,
133- None => connections:: types_list ( & workspace_id, & output) ,
122+ if let Some ( id) = id {
123+ connections:: get ( & workspace_id, & id, & output)
124+ } else {
125+ match command {
126+ Some ( ConnectionsCommands :: New ) => connections_new:: run ( & workspace_id) ,
127+ Some ( ConnectionsCommands :: List { output } ) => {
128+ connections:: list ( & workspace_id, & output)
129+ }
130+ Some ( ConnectionsCommands :: Create { command, name, source_type, config, output } ) => {
131+ match command {
132+ Some ( ConnectionsCreateCommands :: List { name, output } ) => {
133+ match name. as_deref ( ) {
134+ Some ( name) => connections:: types_get ( & workspace_id, name, & output) ,
135+ None => connections:: types_list ( & workspace_id, & output) ,
136+ }
134137 }
135- }
136- None => {
137- let missing: Vec < & str > = [
138- name. is_none ( ) . then_some ( "--name" ) ,
139- source_type. is_none ( ) . then_some ( "--type" ) ,
140- config. is_none ( ) . then_some ( "--config" ) ,
141- ] . into_iter ( ) . flatten ( ) . collect ( ) ;
142- if !missing. is_empty ( ) {
143- eprintln ! ( "error: missing required arguments: {}" , missing. join( ", " ) ) ;
144- std:: process:: exit ( 1 ) ;
138+ None => {
139+ let missing: Vec < & str > = [
140+ name. is_none ( ) . then_some ( "--name" ) ,
141+ source_type. is_none ( ) . then_some ( "--type" ) ,
142+ config. is_none ( ) . then_some ( "--config" ) ,
143+ ] . into_iter ( ) . flatten ( ) . collect ( ) ;
144+ if !missing. is_empty ( ) {
145+ eprintln ! ( "error: missing required arguments: {}" , missing. join( ", " ) ) ;
146+ std:: process:: exit ( 1 ) ;
147+ }
148+ connections:: create (
149+ & workspace_id,
150+ & name. unwrap ( ) ,
151+ & source_type. unwrap ( ) ,
152+ & config. unwrap ( ) ,
153+ & output,
154+ )
145155 }
146- connections:: create (
147- & workspace_id,
148- & name. unwrap ( ) ,
149- & source_type. unwrap ( ) ,
150- & config. unwrap ( ) ,
151- & output,
152- )
153156 }
154157 }
158+ Some ( ConnectionsCommands :: Refresh { connection_id } ) => {
159+ connections:: refresh ( & workspace_id, & connection_id)
160+ }
161+ None => {
162+ use clap:: CommandFactory ;
163+ let mut cmd = Cli :: command ( ) ;
164+ cmd. build ( ) ;
165+ cmd. find_subcommand_mut ( "connections" ) . unwrap ( ) . print_help ( ) . unwrap ( ) ;
166+ }
155167 }
156- ConnectionsCommands :: Refresh { connection_id } => {
157- connections:: refresh ( & workspace_id, & connection_id)
158- }
159- _ => eprintln ! ( "not yet implemented" ) ,
160168 }
161169 } ,
162170 Commands :: Tables { command } => match command {
0 commit comments