All files / src/commands/oauth-consumers oauth-consumers.open.command.js

72.22% Statements 13/18
100% Branches 1/1
0% Functions 0/1
72.22% Lines 13/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x           193x 193x  
import { defineCommand } from '../../lib/define-command.js';
import { styleText } from '../../lib/style-text.js';
import { resolveOauthConsumer } from '../../models/oauth-consumer.js';
import { openBrowser } from '../../models/utils.js';
import { consumerKeyOrNameArg } from './oauth-consumers.args.js';
 
export const oauthConsumersOpenCommand = defineCommand({
  description: 'Open an OAuth consumer in the Clever Cloud Console',
  since: '4.8.0',
  args: [consumerKeyOrNameArg],
  async handler(options, keyOrName) {
    const oauthConsumer = await resolveOauthConsumer(keyOrName);
    await openBrowser(
      `/organisations/${oauthConsumer.ownerId}/oauth-consumers/${oauthConsumer.key}`,
      `Opening OAuth consumer ${styleText('blue', oauthConsumer.key)} in the browser…`,
    );
  },
});