Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds command cli config list, Closes #4797 #5171

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions docs/docs/cmd/cli/config/config-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import Global from '/docs/cmd/_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# cli config list

List all self set CLI for Microsoft 365 configurations

## Usage

```sh
m365 cli config list [options]
```

## Options

<Global />

## Remarks

You can get the available settings with the `m365 cli config get` command, see [cli config get](./config-get.mdx) for more information.
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved

nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved
## Examples

List all self set configuration keys with their value

```sh
m365 cli config list
```

## Response

The response below is an example, this may change depending on the configuration you have set
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved

<Tabs>
<TabItem value="JSON">

```json
{
"errorOutput": "stdout"
}
```

</TabItem>
<TabItem value="Text">

```text
errorOutput: stdout
```

</TabItem>
<TabItem value="CSV">

```csv
errorOutput
stdout
```

</TabItem>
<TabItem value="Markdown">

```md
# cli config list

Date: 29/6/2023

Property | Value
---------|-------
errorOutput | stdout
```

</TabItem>
</Tabs>

## More information

- [Configuring the CLI for Microsoft 365](../../../user-guide/configuring-cli.mdx)
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ const sidebars = {
label: 'config get',
id: 'cmd/cli/config/config-get'
},
{
type: 'doc',
label: 'config list',
id: 'cmd/cli/config/config-list'
},
{
type: 'doc',
label: 'config reset',
Expand Down
4 changes: 2 additions & 2 deletions src/cli/Cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1301,8 +1301,8 @@ describe('Cli', () => {
.execute(cliCommandsFolder, ['cli', 'mock', '-x', '1'])
.then(_ => {
try {
// 12 commands from the folder + 4 mocks + cli completion clink update
assert.strictEqual(cli.commands.length, 12 + 5 + 1);
// 13 commands from the folder + 4 mocks + cli completion clink update
assert.strictEqual(cli.commands.length, 13 + 5 + 1);
done();
}
catch (e) {
Expand Down
1 change: 1 addition & 0 deletions src/m365/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
COMPLETION_SH_SETUP: `${prefix} completion sh setup`,
COMPLETION_SH_UPDATE: `${prefix} completion sh update`,
CONFIG_GET: `${prefix} config get`,
CONFIG_LIST: `${prefix} config list`,
CONFIG_RESET: `${prefix} config reset`,
CONFIG_SET: `${prefix} config set`,
CONSENT: `${prefix} consent`,
Expand Down
64 changes: 64 additions & 0 deletions src/m365/cli/commands/config/config-list.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as assert from 'assert';
import * as sinon from 'sinon';
import { telemetry } from '../../../../telemetry';
import { Cli } from '../../../../cli/Cli';
import { Logger } from '../../../../cli/Logger';
import Command from '../../../../Command';
import { pid } from '../../../../utils/pid';
import { session } from '../../../../utils/session';
import { sinonUtil } from '../../../../utils/sinonUtil';
import commands from '../../commands';
const command: Command = require('./config-list');

describe(commands.CONFIG_LIST, () => {
let log: any[];
let logger: Logger;
let loggerSpy: sinon.SinonSpy;

before(() => {
sinon.stub(telemetry, 'trackEvent').callsFake(() => { });
sinon.stub(pid, 'getProcessName').callsFake(() => '');
sinon.stub(session, 'getId').callsFake(() => '');
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved
});

beforeEach(() => {
log = [];
logger = {
log: (msg: string) => {
log.push(msg);
},
logRaw: (msg: string) => {
log.push(msg);
},
logToStderr: (msg: string) => {
log.push(msg);
}
};
loggerSpy = sinon.spy(logger, 'log');
});

afterEach(() => {
sinonUtil.restore(Cli.getInstance().config.all);
});

after(() => {
sinon.restore();
});

it('has correct name', () => {
assert.strictEqual(command.name, commands.CONFIG_LIST);
});

it('has a description', () => {
assert.notStrictEqual(command.description, null);
});

it('returns a list of all the self set properties', async () => {
sinon.stub(Cli.getInstance().config, 'all').resolves({
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved
"errorOutput": "stdout"
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved
});

await command.action(logger, { options: {} });
assert(loggerSpy.calledWith(Cli.getInstance().config.all));
nicodecleyre marked this conversation as resolved.
Show resolved Hide resolved
});
});
20 changes: 20 additions & 0 deletions src/m365/cli/commands/config/config-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Cli } from "../../../../cli/Cli";
import { Logger } from "../../../../cli/Logger";
import AnonymousCommand from "../../../base/AnonymousCommand";
import commands from "../../commands";

class CliConfigListCommand extends AnonymousCommand {
public get name(): string {
return commands.CONFIG_LIST;
}

public get description(): string {
return 'List all self set CLI for Microsoft 365 configurations';
}

public async commandAction(logger: Logger): Promise<void> {
logger.log(Cli.getInstance().config.all);
}
}

module.exports = new CliConfigListCommand();