Skip to content

Commit 84c3584

Browse files
committed
Tone down the colours a little
Signed-off-by: Phil Ewels <[email protected]>
1 parent 342d33a commit 84c3584

File tree

1 file changed

+22
-50
lines changed

1 file changed

+22
-50
lines changed

plugins/nf-tower/src/main/io/seqera/tower/plugin/cli/AuthCommandImpl.groovy

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
6969
return
7070
}
7171

72-
ColorUtil.printColored("Nextflow authentication with Seqera Platform", "cyan bold")
72+
println("Nextflow authentication with Seqera Platform")
7373
ColorUtil.printColored(" - Authentication will be saved to: ${ColorUtil.colorize(getAuthFile().toString(), 'magenta')}", "dim")
7474

7575
apiUrl = normalizeApiUrl(apiUrl)
@@ -96,10 +96,10 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
9696
final deviceAuth = requestDeviceAuthorization(auth0Config)
9797

9898
println ""
99-
ColorUtil.printColored("Confirmation code: ${ColorUtil.colorize(deviceAuth.user_code as String, 'yellow')}", "cyan bold")
99+
println "Confirmation code: ${ColorUtil.colorize(deviceAuth.user_code as String, 'yellow')}"
100100
final urlWithCode = "${deviceAuth.verification_uri}?user_code=${deviceAuth.user_code}"
101-
println "${ColorUtil.colorize('Authentication URL:', 'cyan bold')} ${ColorUtil.colorize(urlWithCode, 'magenta')}"
102-
ColorUtil.printColored("\n[ Press Enter to open in browser ]", "cyan bold")
101+
println "Authentication URL: ${ColorUtil.colorize(urlWithCode, 'magenta')}"
102+
ColorUtil.printColored("\n[ Press Enter to open in browser ]", "bold")
103103

104104
// Wait for Enter key with proper interrupt handling
105105
try {
@@ -129,7 +129,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
129129

130130
// Verify login by calling /user-info
131131
final userInfo = callUserInfoApi(accessToken, apiUrl)
132-
ColorUtil.printColored("\n\nAuthentication successful!", "green")
132+
println "\n\n${ColorUtil.colorize('✔', 'green', true)} Authentication successful"
133133

134134
// Generate PAT
135135
final pat = generatePAT(accessToken, apiUrl)
@@ -139,7 +139,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
139139

140140
// Automatically run configuration
141141
try {
142-
config()
142+
config(false)
143143
} catch( Exception e ) {
144144
ColorUtil.printColored("Configuration setup failed: ${e.message}", "red")
145145
ColorUtil.printColored("You can run 'nextflow auth config' later to set up your configuration.", "dim")
@@ -368,7 +368,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
368368
// Check if seqera-auth.config file exists
369369
final authFile = getAuthFile()
370370
if( !Files.exists(authFile) ) {
371-
ColorUtil.printColored("No previous login found.", "green")
371+
println "No previous login found.\n"
372372
return
373373
}
374374
// Read token from seqera-auth.config file
@@ -399,7 +399,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
399399
// Validate token by calling /user-info API
400400
try {
401401
final userInfo = callUserInfoApi(existingToken as String, apiUrl)
402-
ColorUtil.printColored(" - Token is valid for user: ${ColorUtil.colorize(userInfo.userName as String, 'cyan bold')}", "dim")
402+
ColorUtil.printColored(" - Token is valid for user: ${ColorUtil.colorize(userInfo.userName as String, 'bold')}", "dim")
403403
} catch( Exception e ) {
404404
ColorUtil.printColored("Failed to validate token: ${e.message}", "red")
405405
}
@@ -416,7 +416,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
416416
ColorUtil.printColored("Warning: Access token not deleted, as using enterprise installation: ${ColorUtil.colorize(apiUrl, 'magenta')}", "yellow")
417417
}
418418

419-
final confirmed = promptForYesNo("\n${ColorUtil.colorize('Continue with logout?', 'cyan bold')} (${ColorUtil.colorize('Y', 'green')}/n): ", true)
419+
final confirmed = promptForYesNo("\n${ColorUtil.colorize('Continue with logout?', 'bold')} (${ColorUtil.colorize('Y', 'green')}/n): ", true)
420420

421421
if( !confirmed ) {
422422
println("Logout cancelled.")
@@ -469,7 +469,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
469469
throw new RuntimeException("Failed to delete token: ${error}")
470470
}
471471

472-
ColorUtil.printColored("\nToken successfully deleted from Seqera Platform.", "green")
472+
println "\n${ColorUtil.colorize('✔', 'green', true)} Token successfully deleted from Seqera Platform."
473473
}
474474

475475
private void removeAuthFromConfig() {
@@ -488,11 +488,11 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
488488
Files.delete(authFile)
489489
}
490490

491-
ColorUtil.printColored("Authentication removed from Nextflow config.", "green")
491+
println "${ColorUtil.colorize('✔', 'green', true)} Authentication removed from Nextflow config."
492492
}
493493

494494
@Override
495-
void config() {
495+
void config(Boolean showHeader = true) {
496496
// Read from both main config and seqera-auth.config file
497497
final builder = new ConfigBuilder().setHomeDir(Const.APP_HOME_DIR).setCurrentDir(Const.APP_HOME_DIR)
498498
final configObject = builder.buildConfigObject()
@@ -508,12 +508,14 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
508508
return
509509
}
510510

511-
ColorUtil.printColored("Nextflow Seqera Platform configuration", "cyan bold")
512-
ColorUtil.printColored(" - Config file: ${ColorUtil.colorize(getAuthFile().toString(), 'magenta')}", "dim")
511+
if (showHeader) {
512+
println "Nextflow Seqera Platform configuration"
513+
ColorUtil.printColored(" - Config file: ${ColorUtil.colorize(getAuthFile().toString(), 'magenta')}", "dim")
513514

514-
// Check if token is from environment variable
515-
if( !towerConfig['accessToken'] && SysEnv.get('TOWER_ACCESS_TOKEN') ) {
516-
ColorUtil.printColored(" - Using access token from TOWER_ACCESS_TOKEN environment variable", "dim")
515+
// Check if token is from environment variable
516+
if( !towerConfig['accessToken'] && SysEnv.get('TOWER_ACCESS_TOKEN') ) {
517+
ColorUtil.printColored(" - Using access token from TOWER_ACCESS_TOKEN environment variable", "dim")
518+
}
517519
}
518520

519521
try {
@@ -535,12 +537,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
535537
// Save updated config only if changes were made
536538
if( configChanged ) {
537539
writeConfig(config, workspaceResult.metadata as Map)
538-
539-
// Show the new configuration
540-
println "\nNew configuration:"
541-
showCurrentConfig(config, existingToken as String, endpoint as String)
542-
543-
ColorUtil.printColored("\nConfiguration saved to ${ColorUtil.colorize(getAuthFile().toString(), 'magenta')}", "green")
540+
println "\n${ColorUtil.colorize('✔', 'green', true)} Configuration saved to ${ColorUtil.colorize(getAuthFile().toString(), 'magenta')}"
544541
}
545542

546543
// Configure compute environment for the workspace (always run after workspace selection)
@@ -559,31 +556,6 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
559556
}
560557
}
561558

562-
private void showCurrentConfig(Map config, String accessToken, String endpoint) {
563-
// Show workflow monitoring status
564-
final monitoringEnabled = config.get('tower.enabled', false)
565-
println " ${ColorUtil.colorize('Workflow monitoring:', 'cyan')} ${monitoringEnabled ? ColorUtil.colorize('enabled', 'green') : ColorUtil.colorize('disabled', 'red')}"
566-
567-
// Show workspace setting
568-
final workspaceId = config.get('tower.workspaceId')
569-
if( workspaceId ) {
570-
// Try to get workspace details from API for display
571-
final workspaceDetails = getWorkspaceDetailsFromApi(accessToken, endpoint, workspaceId as String)
572-
if( workspaceDetails ) {
573-
final details = workspaceDetails as Map
574-
println " ${ColorUtil.colorize('Default workspace:', 'cyan')} ${ColorUtil.colorize(workspaceId as String, 'magenta')} ${ColorUtil.colorize('[' + details.orgName + ' / ' + details.workspaceName + ']', 'dim', true)}"
575-
} else {
576-
println " ${ColorUtil.colorize('Default workspace:', 'cyan')} ${ColorUtil.colorize(workspaceId as String, 'magenta')}"
577-
}
578-
} else {
579-
println " ${ColorUtil.colorize('Default workspace:', 'cyan')} ${ColorUtil.colorize('None (Personal workspace)', 'magenta')}"
580-
}
581-
582-
// Show API endpoint
583-
final apiEndpoint = config.get('tower.endpoint') ?: endpoint
584-
println " ${ColorUtil.colorize('API endpoint:', 'cyan', true)} $apiEndpoint"
585-
}
586-
587559
private boolean configureEnabled(Map config) {
588560
final currentEnabled = config.get('tower.enabled', false)
589561

@@ -592,7 +564,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
592564
ColorUtil.printColored(" When disabled, you can enable per-run with the ${ColorUtil.colorize('-with-tower', 'cyan')} flag", "dim")
593565
println ""
594566

595-
final promptText = "${ColorUtil.colorize('Enable workflow monitoring for all runs?', 'cyan bold', true)} (${currentEnabled ? ColorUtil.colorize('Y', 'green') + '/n' : 'y/' + ColorUtil.colorize('N', 'red')}): "
567+
final promptText = "${ColorUtil.colorize('Enable workflow monitoring for all runs?', 'bold', true)} (${currentEnabled ? ColorUtil.colorize('Y', 'green') + '/n' : 'y/' + ColorUtil.colorize('N', 'red')}): "
596568
final input = promptForYesNo(promptText, currentEnabled)
597569

598570
if( input == null ) {
@@ -1088,7 +1060,7 @@ class AuthCommandImpl implements CmdAuth.AuthCommand {
10881060
col3Width = Math.max(col3Width, 10) + 2
10891061

10901062
// Add table header
1091-
lines.add(ColorUtil.colorize("${'Setting'.padRight(col1Width)} ${'Value'.padRight(col2Width)} Source", "cyan bold"))
1063+
lines.add(ColorUtil.colorize("${'Setting'.padRight(col1Width)} ${'Value'.padRight(col2Width)} Source", "bold"))
10921064
lines.add("${'-' * col1Width} ${'-' * col2Width} ${'-' * col3Width}".toString())
10931065

10941066
// Add rows

0 commit comments

Comments
 (0)