Skip to content

Commit 9554a5f

Browse files
authored
feat(cli-test): include a verbose global option for cli commands (#2147)
1 parent 2874654 commit 9554a5f

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

packages/cli-test/src/cli/cli-process.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ describe('SlackCLIProcess class', () => {
140140
);
141141
spawnProcessSpy.resetHistory();
142142
});
143+
it('should map verbose option to `--verbose`', async () => {
144+
let cmd = new SlackCLIProcess(['help'], { verbose: true });
145+
await cmd.execAsync();
146+
sandbox.assert.calledWith(spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--verbose']));
147+
spawnProcessSpy.resetHistory();
148+
cmd = new SlackCLIProcess(['help']);
149+
await cmd.execAsync();
150+
sandbox.assert.neverCalledWith(spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--verbose']));
151+
});
143152
});
144153
describe('command options', () => {
145154
it('should pass command-level key/value options to command in the form `--<key> value`', async () => {

packages/cli-test/src/cli/cli-process.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface SlackCLIGlobalOptions {
3939
team?: string;
4040
/** @description Access token to use when making Slack API calls. */
4141
token?: string;
42+
/** @description Print debug logging and additional CLI information. */
43+
verbose?: boolean;
4244
}
4345

4446
export type SlackCLIHostTargetOptions = Pick<SlackCLIGlobalOptions, 'qa' | 'dev' | 'apihost'>;
@@ -144,6 +146,9 @@ export class SlackCLIProcess {
144146
if (opts.token) {
145147
cmd = cmd.concat(['--token', opts.token]);
146148
}
149+
if (opts.verbose) {
150+
cmd = cmd.concat(['--verbose']);
151+
}
147152
} else {
148153
cmd = cmd.concat(['--skip-update', '--force', '--app', 'deployed']);
149154
}

packages/cli-test/src/cli/commands/auth.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ import {
77

88
import type { ShellProcess } from '../../types/shell';
99

10+
type AuthLoginNoPromptArguments = SlackCLIHostTargetOptions & Pick<SlackCLIGlobalOptions, 'verbose'>;
11+
type AuthLoginChallengeExchangeArugments = SlackCLIHostTargetOptions & {
12+
/** @description Challenge string extracted from the Slack client UI after submitting the auth slash command. */
13+
challenge: string;
14+
/** @description The `authTicket` output from `loginNoPrompt`; required to complete the login flow. */
15+
authTicket: string;
16+
} & Pick<SlackCLIGlobalOptions, 'verbose'>;
17+
1018
export default {
1119
/**
1220
* `slack login --no-prompt`; initiates a CLI login flow. The `authTicketSlashCommand` returned should be entered
1321
* into the Slack client, and the challenge code retrieved and fed into the `loginChallengeExchange` method to
1422
* complete the CLI login flow.
1523
*/
16-
loginNoPrompt: async function loginNoPrompt(args?: SlackCLIHostTargetOptions): Promise<{
24+
loginNoPrompt: async function loginNoPrompt(args?: AuthLoginNoPromptArguments): Promise<{
1725
/** @description Command output */
1826
output: ShellProcess['output'];
1927
/**
@@ -57,12 +65,7 @@ export default {
5765
* @returns
5866
*/
5967
loginChallengeExchange: async function loginChallengeExchange(
60-
args: SlackCLIHostTargetOptions & {
61-
/** @description Challenge string extracted from the Slack client UI after submitting the auth slash command. */
62-
challenge: string;
63-
/** @description The `authTicket` output from `loginNoPrompt`; required to complete the login flow. */
64-
authTicket: string;
65-
},
68+
args: AuthLoginChallengeExchangeArugments,
6669
): Promise<string> {
6770
const cmd = new SlackCLIProcess(['login'], args, {
6871
'--no-prompt': true,

0 commit comments

Comments
 (0)