@@ -56,8 +56,8 @@ public void run(CliContext context, CommandLine args) {
5656 (organization .isPresent () ?
5757 " and your current organization is " + organization .get ().getName () :
5858 "." ));
59- io .println ("Change your organization with the command organization." );
60- io .println ("Inspect and change your current settings with the command config." );
59+ io .println ("You can change your organization with the command organization." );
60+ io .println ("You can change your current settings with the command config." );
6161 return ;
6262 }
6363
@@ -75,7 +75,7 @@ public void run(CliContext context, CommandLine args) {
7575 login (this .ctx , args , Optional .absent ());
7676 }
7777
78- public void login (CliContext ctx , CommandLine args , Optional <String > serverAddress ) {
78+ public boolean login (CliContext ctx , CommandLine args , Optional <String > serverAddress ) {
7979 Io io = ctx .getIo ();
8080 username = getLoginInfo (args , username , "u" , "username: " , io );
8181 password = getLoginInfo (args , null , "p" , "password: " , io );
@@ -89,21 +89,22 @@ public void login(CliContext ctx, CommandLine args, Optional<String> serverAddre
8989
9090 if (!TmcUtil .tryToLogin (ctx , account , password )) {
9191 ctx .getSettings ().setAccount (ctx , new Account ());
92- return ;
92+ username = null ;
93+ return false ;
9394 }
9495
9596 OrganizationCommand organizationCommand = new OrganizationCommand ();
96- Optional <Organization > organization = organizationCommand .chooseOrganization (ctx , Optional .of (args ));
97+ Optional <Organization > organization = organizationCommand .chooseOrganization (ctx , Optional .fromNullable (args ));
9798 if (!organization .isPresent ()) {
98- return ;
99+ return false ;
99100 }
100101 account .setOrganization (organization );
101102
102- boolean sendDiagnostics = getBooleanAnswerFromUser (Optional .of (username ),
103+ boolean sendDiagnostics = getBooleanAnswerFromUser (Optional .fromNullable (username ),
103104 "Do you want to send crash reports for client development?" ,
104105 ctx .getSettings ().getSendDiagnostics (), io );
105106 account .setSendDiagnostics (sendDiagnostics );
106- boolean sendAnalytics = getBooleanAnswerFromUser (Optional .of (username ),
107+ boolean sendAnalytics = getBooleanAnswerFromUser (Optional .fromNullable (username ),
107108 "Do you want to send analytics data for research?" ,
108109 ctx .getSettings ().isSpywareEnabled (), io );
109110 account .setSendAnalytics (sendAnalytics );
@@ -112,14 +113,15 @@ public void login(CliContext ctx, CommandLine args, Optional<String> serverAddre
112113 list .addAccount (account );
113114 if (!SettingsIo .saveAccountList (list )) {
114115 io .errorln ("Failed to write the accounts file." );
115- return ;
116+ return false ;
116117 }
117118
118119 ctx .getAnalyticsFacade ().saveAnalytics ("login" );
119120
120121 io .println ("Login successful." );
121122 io .println ("You can change your organization with the command organization, " +
122- "and inspect and change other settings with the command config." );
123+ "and change other settings with the command config." );
124+ return true ;
123125 }
124126
125127 private String getLoginInfo (CommandLine line , String oldValue , String option , String prompt , Io io ) {
0 commit comments