@@ -323,7 +323,16 @@ def init(project_root, shuttle, description):
323323 config = load_user_config ()
324324 username = config .get ("sftp_username" )
325325 if not username :
326- console .print ("[bold red]No SFTP username found in user config. Please run 'chipfoundry config' first.[/bold red]" )
326+ try :
327+ me = _api_get ("/auth/cli/whoami" )
328+ username = me .get ("sftp_username" )
329+ if username :
330+ config ["sftp_username" ] = username
331+ save_user_config (config )
332+ except SystemExit :
333+ pass
334+ if not username :
335+ console .print ("[bold red]No SFTP account linked to your platform account. Please run 'cf login' first.[/bold red]" )
327336 raise click .Abort ()
328337
329338 gds_dir = Path (project_root ) / 'gds'
@@ -1313,10 +1322,14 @@ def push(project_root, sftp_host, sftp_username, sftp_key, project_id, project_n
13131322 console .print ("Run [bold]cf login[/bold] to authenticate before pushing." )
13141323 raise click .Abort ()
13151324 if not sftp_username :
1316- sftp_username = config .get ("sftp_username" )
1325+ me = _api_get ("/auth/cli/whoami" )
1326+ sftp_username = me .get ("sftp_username" )
13171327 if not sftp_username :
1318- console .print ("[bold red]No SFTP username provided and not found in config. Please run 'chipfoundry init' or provide --sftp-username.[/bold red]" )
1328+ console .print ("[bold red]No SFTP account linked to your platform account.[/bold red]" )
1329+ console .print ("Contact support or provide --sftp-username." )
13191330 raise click .Abort ()
1331+ config ["sftp_username" ] = sftp_username
1332+ save_user_config (config )
13201333 if not sftp_key :
13211334 sftp_key = config .get ("sftp_key" )
13221335
@@ -1495,10 +1508,14 @@ def pull(project_name, output_dir, sftp_host, sftp_username, sftp_key):
14951508 console .print ("Run [bold]cf login[/bold] to authenticate before pulling." )
14961509 raise click .Abort ()
14971510 if not sftp_username :
1498- sftp_username = config .get ("sftp_username" )
1511+ me = _api_get ("/auth/cli/whoami" )
1512+ sftp_username = me .get ("sftp_username" )
14991513 if not sftp_username :
1500- console .print ("[bold red]No SFTP username provided and not found in config. Please run 'cf config' or provide --sftp-username.[/bold red]" )
1514+ console .print ("[bold red]No SFTP account linked to your platform account.[/bold red]" )
1515+ console .print ("Contact support or provide --sftp-username." )
15011516 raise click .Abort ()
1517+ config ["sftp_username" ] = sftp_username
1518+ save_user_config (config )
15021519 if not sftp_key :
15031520 sftp_key = config .get ("sftp_key" )
15041521
@@ -1751,10 +1768,14 @@ def status(sftp_host, sftp_username, sftp_key, json_output, show_all):
17511768 if not platform_id :
17521769 console .print ("[dim]Tip: Run [bold]cf link[/bold] to connect this project to the platform.[/dim]\n " )
17531770 if not sftp_username :
1754- sftp_username = config .get ("sftp_username" )
1771+ me = _api_get ("/auth/cli/whoami" )
1772+ sftp_username = me .get ("sftp_username" )
17551773 if not sftp_username :
1756- console .print ("[red]No SFTP username provided and not found in config. Please run 'cf config' or provide --sftp-username.[/red]" )
1774+ console .print ("[red]No SFTP account linked to your platform account.[/red]" )
1775+ console .print ("Contact support or provide --sftp-username." )
17571776 raise click .Abort ()
1777+ config ["sftp_username" ] = sftp_username
1778+ save_user_config (config )
17581779 if not sftp_key :
17591780 sftp_key = config .get ("sftp_key" )
17601781
@@ -1885,10 +1906,14 @@ def tapeouts(sftp_host, sftp_username, sftp_key, limit, days):
18851906 """Show all tapeout runs (archived projects) with their timestamps."""
18861907 config = load_user_config ()
18871908 if not sftp_username :
1888- sftp_username = config .get ("sftp_username" )
1909+ me = _api_get ("/auth/cli/whoami" )
1910+ sftp_username = me .get ("sftp_username" )
18891911 if not sftp_username :
1890- console .print ("[red]No SFTP username provided and not found in config. Please run 'cf config' or provide --sftp-username.[/red]" )
1912+ console .print ("[red]No SFTP account linked to your platform account.[/red]" )
1913+ console .print ("Contact support or provide --sftp-username." )
18911914 raise click .Abort ()
1915+ config ["sftp_username" ] = sftp_username
1916+ save_user_config (config )
18921917 if not sftp_key :
18931918 sftp_key = config .get ("sftp_key" )
18941919
@@ -2071,10 +2096,14 @@ def confirm(project_root, sftp_host, sftp_username, sftp_key, project_name):
20712096 # Load user config for defaults
20722097 config = load_user_config ()
20732098 if not sftp_username :
2074- sftp_username = config .get ("sftp_username" )
2099+ me = _api_get ("/auth/cli/whoami" )
2100+ sftp_username = me .get ("sftp_username" )
20752101 if not sftp_username :
2076- console .print ("[bold red]No SFTP username provided and not found in config. Please run 'cf config' or provide --sftp-username.[/bold red]" )
2102+ console .print ("[bold red]No SFTP account linked to your platform account.[/bold red]" )
2103+ console .print ("Contact support or provide --sftp-username." )
20772104 raise click .Abort ()
2105+ config ["sftp_username" ] = sftp_username
2106+ save_user_config (config )
20782107 if not sftp_key :
20792108 sftp_key = config .get ("sftp_key" )
20802109
@@ -3886,9 +3915,14 @@ def login_cmd():
38863915 config ['api_key' ] = api_key
38873916 if user_email :
38883917 config ['user_email' ] = user_email
3918+ sftp_username = poll_data .get ('sftp_username' )
3919+ if sftp_username :
3920+ config ['sftp_username' ] = sftp_username
38893921 save_user_config (config )
38903922
38913923 console .print (f"\n [green]✓ Logged in as { user_email or 'authenticated user' } [/green]" )
3924+ if sftp_username :
3925+ console .print (f" SFTP account: { sftp_username } " )
38923926 console .print (f" API key saved to { get_config_path ()} " )
38933927 return
38943928
0 commit comments