Skip to content

Commit 9d6cd95

Browse files
committed
Login help clarifications
1 parent 8552ed3 commit 9d6cd95

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

src/Command/Auth/ApiTokenLoginCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4444
}
4545
if (!$input->isInteractive()) {
4646
$this->stdErr->writeln('Non-interactive use of this command is not supported.');
47-
$this->stdErr->writeln("\n" . $this->getApiTokenHelp('comment'));
47+
$this->stdErr->writeln("\n" . $this->getNonInteractiveAuthHelp('comment'));
4848
return 1;
4949
}
5050

src/Command/Auth/BrowserLoginCommand.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ protected function configure()
3232
->addOption('force', 'f', InputOption::VALUE_NONE, 'Log in again, even if already logged in');
3333
Url::configureInput($this->getDefinition());
3434

35-
$help = 'Use this command to log in to the ' . $applicationName . ' using a browser.'
36-
. "\n\n" . $this->getApiTokenHelp();
37-
$this->setHelp($help);
35+
$executable = $this->config()->get('application.executable');
36+
$help = 'Use this command to log in to the ' . $applicationName . ' using a web browser.'
37+
. "\n\nIt launches a temporary local website which redirects you to log in if necessary, and then captures the resulting authorization code."
38+
. "\n\nYour system's default browser will be used. You can override this using the <info>--browser</info> option."
39+
. "\n\nAlternatively, to log in using an API token (without a browser), run: <info>$executable auth:api-token-login</info>"
40+
. "\n\n" . $this->getNonInteractiveAuthHelp();
41+
$this->setHelp(\wordwrap($help, 80));
3842
}
3943

4044
protected function execute(InputInterface $input, OutputInterface $output)
@@ -44,8 +48,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
4448
return 1;
4549
}
4650
if (!$input->isInteractive()) {
47-
$this->stdErr->writeln('Non-interactive login is not supported.');
48-
$this->stdErr->writeln("\n" . $this->getApiTokenHelp('comment'));
51+
$this->stdErr->writeln('Non-interactive use of this command is not supported.');
52+
$this->stdErr->writeln("\n" . $this->getNonInteractiveAuthHelp('comment'));
4953
return 1;
5054
}
5155
if ($this->config()->getSessionId() !== 'default' || count($this->api()->listSessionIds()) > 1) {
@@ -174,7 +178,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
174178
$this->stdErr->writeln('<options=bold>Help:</>');
175179
$this->stdErr->writeln(' Leave this command running during login.');
176180
$this->stdErr->writeln(' If you need to quit, use Ctrl+C.');
177-
$this->stdErr->writeln("\n" . preg_replace('/^/m', ' ', $this->getApiTokenHelp()));
178181
$this->stdErr->writeln('');
179182

180183
// Wait for the file to be filled with an OAuth2 authorization code.

src/Command/Auth/PasswordLoginCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function configure()
3232
. $accountsUrl . '/user/password</info>'
3333
. "\n\nAlternatively, to log in to the CLI with a browser, run:\n <info>"
3434
. $executable . ' auth:browser-login</info>'
35-
. "\n\n" . $this->getApiTokenHelp();
35+
. "\n\n" . $this->getNonInteractiveAuthHelp();
3636
$this->setHelp($help);
3737
}
3838

@@ -43,8 +43,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
4343
return 1;
4444
}
4545
if (!$input->isInteractive()) {
46-
$this->stdErr->writeln('Non-interactive login is not supported.');
47-
$this->stdErr->writeln("\n" . $this->getApiTokenHelp('comment'));
46+
$this->stdErr->writeln('Non-interactive use of this command is not supported.');
47+
$this->stdErr->writeln("\n" . $this->getNonInteractiveAuthHelp('comment'));
4848
return 1;
4949
}
5050

src/Command/CommandBase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,17 +1560,17 @@ public function isEnabled()
15601560
}
15611561

15621562
/**
1563-
* Get help on how to use API tokens.
1563+
* Get help on how to use API tokens non-interactively.
15641564
*
15651565
* @param string $tag
15661566
*
15671567
* @return string
15681568
*/
1569-
protected function getApiTokenHelp($tag = 'info')
1569+
protected function getNonInteractiveAuthHelp($tag = 'info')
15701570
{
1571-
$executable = $this->config()->get('application.executable');
1571+
$prefix = $this->config()->get('application.env_prefix');
15721572

1573-
return "To log in using an API token, run: <$tag>$executable auth:api-token-login</$tag>";
1573+
return "To authenticate non-interactively, configure an API token using the <$tag>${prefix}TOKEN</$tag> environment variable.";
15741574
}
15751575

15761576
/**

0 commit comments

Comments
 (0)