• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / boxcli / 10810816048

11 Sep 2024 11:36AM CUT coverage: 86.569% (-0.05%) from 86.616%
10810816048

Pull #542

github

web-flow
Merge a647aad97 into 0ed1618f5
Pull Request #542: docs: Add examples to file/folder metadata commands

1191 of 1536 branches covered (77.54%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 4 files covered. (100.0%)

1 existing line in 1 file now uncovered.

4281 of 4785 relevant lines covered (89.47%)

310.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.0
/src/commands/configure/environments/switch-user.js
1
'use strict';
2

3
const BoxCommand = require('../../../box-command');
8✔
4
const { flags } = require('@oclif/command');
8✔
5
const chalk = require('chalk');
8✔
6

7
class EnvironmentsSwitchUserCommand extends BoxCommand {
8
        async run() {
9
                const { flags, args } = this.parse(EnvironmentsSwitchUserCommand);
×
10

11
                let environmentsObj = await this.getEnvironments();
×
12
                let environment = environmentsObj.environments[environmentsObj.default];
×
13

14
                if (flags.default && !args.userID) {
×
15
                        environment.useDefaultAsUser = false;
×
16
                } else if (args.userID && !flags.default) {
×
17
                        environment.useDefaultAsUser = true;
×
18
                        environment.defaultAsUserId = args.userID;
×
19
                } else {
20
                        throw new Error('Either a userID argument or --default flag must be passed, but not both');
×
21
                }
22

23
                await this.updateEnvironments(environmentsObj);
×
24
                this.info(chalk`{green User set to ${args.userID || 'default'}}`);
×
25
        }
26
}
27

28
// @NOTE: This command does not require a client to be set up
29
EnvironmentsSwitchUserCommand.noClient = true;
8✔
30

31
EnvironmentsSwitchUserCommand.description = 'Switch the default Box user to run commands as';
8✔
32

33
EnvironmentsSwitchUserCommand.flags = {
8✔
34
        ...BoxCommand.minFlags,
35
};
36

37
EnvironmentsSwitchUserCommand.args = [
8✔
38
        {
39
                name: 'userID',
40
                hidden: false,
41
                required: false,
42
                description: 'The user ID to switch to'
43
        }
44
];
45

46
EnvironmentsSwitchUserCommand.flags = {
8✔
47
        ...BoxCommand.flags,
48
        default: flags.boolean({
49
                description: 'Switch to the default user, i.e. the Service Account'
50
        }),
51
};
52

53
module.exports = EnvironmentsSwitchUserCommand;
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc