@@ -26,16 +26,36 @@ pub struct Args {
2626 #[ clap( long, short) ]
2727 service : Option < String > ,
2828
29- /// The team to link to.
29+ /// The team to link to (deprecated: use --workspace instead) .
3030 #[ clap( long, short) ]
3131 team : Option < String > ,
32+
33+ /// The workspace to link to.
34+ #[ clap( long, short) ]
35+ workspace : Option < String > ,
3236}
3337
3438pub async fn command ( args : Args ) -> Result < ( ) > {
3539 let mut configs = Configs :: new ( ) ?;
3640
41+ // Support both team (deprecated) and workspace arguments
42+ let workspace_arg = match ( args. team . as_ref ( ) , args. workspace . as_ref ( ) ) {
43+ ( Some ( _) , None ) => {
44+ eprintln ! (
45+ "{}" ,
46+ "Warning: The --team flag is deprecated. Please use --workspace instead." . yellow( )
47+ ) ;
48+ args. team
49+ }
50+ ( None , workspace) => workspace. cloned ( ) ,
51+ ( Some ( _) , Some ( _) ) => {
52+ eprintln ! ( "{}" , "Warning: Both --team and --workspace provided. Using --workspace. The --team flag is deprecated." . yellow( ) ) ;
53+ args. workspace
54+ }
55+ } ;
56+
3757 let workspaces = workspaces ( ) . await ?;
38- let workspace = select_workspace ( args. project . clone ( ) , args . team , workspaces) ?;
58+ let workspace = select_workspace ( args. project . clone ( ) , workspace_arg , workspaces) ?;
3959
4060 let project = select_project ( workspace, args. project . clone ( ) ) ?;
4161
@@ -149,14 +169,14 @@ fn select_project(
149169 fake_select ( "Select a project" , & project. to_string ( ) ) ;
150170 project
151171 } else {
152- return Err ( RailwayError :: ProjectNotFoundInTeam (
172+ return Err ( RailwayError :: ProjectNotFoundInWorkspace (
153173 project,
154174 workspace. name ( ) . to_owned ( ) ,
155175 )
156176 . into ( ) ) ;
157177 }
158178 } else {
159- prompt_team_projects ( projects) ?
179+ prompt_workspace_projects ( projects) ?
160180 }
161181 } ) ;
162182 Ok ( project)
@@ -182,18 +202,18 @@ fn select_workspace(
182202 prompt_workspaces ( workspaces) ?
183203 }
184204 }
185- ( None , Some ( team_arg ) ) | ( Some ( _) , Some ( team_arg ) ) => {
205+ ( None , Some ( workspace_arg ) ) | ( Some ( _) , Some ( workspace_arg ) ) => {
186206 if let Some ( workspace) = workspaces. iter ( ) . find ( |w| {
187- w. team_id ( )
188- . is_some_and ( |id| id . to_lowercase ( ) == team_arg . to_lowercase ( ) )
189- || w. name ( ) . to_lowercase ( ) == team_arg . to_lowercase ( )
207+ w. id ( ) . to_lowercase ( ) == workspace_arg . to_lowercase ( )
208+ || w . team_id ( ) . map ( str :: to_lowercase ) == Some ( workspace_arg . to_lowercase ( ) )
209+ || w. name ( ) . to_lowercase ( ) == workspace_arg . to_lowercase ( )
190210 } ) {
191211 fake_select ( "Select a workspace" , workspace. name ( ) ) ;
192212 workspace. clone ( )
193- } else if team_arg . to_lowercase ( ) == "personal" {
213+ } else if workspace_arg . to_lowercase ( ) == "personal" {
194214 bail ! ( RailwayError :: NoPersonalWorkspace ) ;
195215 } else {
196- return Err ( RailwayError :: TeamNotFound ( team_arg . clone ( ) ) . into ( ) ) ;
216+ return Err ( RailwayError :: WorkspaceNotFound ( workspace_arg . clone ( ) ) . into ( ) ) ;
197217 }
198218 }
199219 ( None , None ) => prompt_workspaces ( workspaces) ?,
@@ -212,7 +232,7 @@ fn prompt_workspaces(workspaces: Vec<Workspace>) -> Result<Workspace> {
212232 prompt_options ( "Select a workspace" , workspaces)
213233}
214234
215- fn prompt_team_projects ( projects : Vec < Project > ) -> Result < Project , anyhow:: Error > {
235+ fn prompt_workspace_projects ( projects : Vec < Project > ) -> Result < Project , anyhow:: Error > {
216236 prompt_options ( "Select a project" , projects)
217237}
218238
@@ -277,7 +297,7 @@ impl From<Project> for NormalisedProject {
277297 } )
278298 . collect ( ) ,
279299 ) ,
280- Project :: Team ( project) => NormalisedProject :: new (
300+ Project :: Workspace ( project) => NormalisedProject :: new (
281301 project. id ,
282302 project. name ,
283303 project
0 commit comments