Skip to content

(DOCS) Add CLI reference documentation #120

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

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
66 changes: 66 additions & 0 deletions docs/reference/cli/config/command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# dsc config

## Synopsis

Apply a configuration document.

## Syntax

```sh
dsc config [Options] <COMMAND>
```

## Description

The `dsc config` command includes subcommands for managing the resource instances defined in a DSC
configuration document. To manage resources directly, see the [dsc resource][01] command.

## Commands

### get

The `get` command retrieves the current state of the resource instances in a configuration
document. For more information, see [dsc config get][02].

### set

The `set` command enforces the desired state of the resource instances in a configuration document.
For more information, see [dsc config set][03].

### test

The `test` command verifies whether the resource instances in a configuration document are in the
desired state. For more information, see [dsc config test][04].

### help

The `help` command returns help information for this command or a subcommand.

To get the help for a command or subcommand, use the syntax:

```sh
dsc config help [<SUBCOMMAND>]
```

For example, `dsc config help` gets the help for this command. `dsc config help set` gets the help
for the `set` subcommand.

You can also use the [--help](#h---help) option on the command or subcommand to display the help
information. For example, `dsc config --help` or `dsc config set --help`.

## Options

### -h, --help

Displays the help for the current command or subcommand. When you specify this option, the
application ignores all options and arguments after this one.

```yaml
Type: Boolean
Mandatory: false
```

[01]: ../resource/command.md
[02]: get.md
[03]: set.md
[04]: test.md
72 changes: 72 additions & 0 deletions docs/reference/cli/config/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# dsc config get

## Synopsis

Retrieves the current state of resource instances in a configuration document.

## Syntax

```sh
dsc config get [Options]
```

## Description

The `get` subcommand returns the current state of the resource instances in a configuration
document. When this command runs, DSC validates the configuration document before invoking the get
operation for each resource instance defined in the document.

The configuration document must be passed to this command as JSON or YAML over stdin.

## Examples

### Example 1 - Get the current state of a configuration's resource instances

The command returns the actual state for the resource instances defined in the configuration
document saved as `example.dsc.config.yaml`.

```yaml
# example.dsc.config.yaml
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: Windows only
type: DSC/AssertionGroup
properties:
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Current user registry example
type: Microsoft.Windows/Registry
properties:
keyPath: HKCU\example
_ensure: Present
dependsOn:
- '[DSC/Assertion]Windows only'
```

```sh
cat ./example.dsc.config.yaml | dsc config get
```

## Options

### -h, --help

Displays the help for the current command or subcommand. When you specify this option, the
application ignores all options and arguments after this one.

```yaml
Type: Boolean
Mandatory: false
```

## Output

This command returns JSON output that includes whether the operation or any resources raised any
errors, the collection of messages emitted during the operation, and the get operation results for
every instance. For more information, see [dsc config get result schema][01].

[01]: ../../schemas/outputs/config/get.md
73 changes: 73 additions & 0 deletions docs/reference/cli/config/set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# dsc config set

## Synopsis

Enforces the desired state of resource instances in a configuration document.

## Syntax

```sh
dsc config set [Options]
```

## Description

The `set` subcommand enforces the desired state of the resource instances in a configuration
document. When this command runs, DSC validates the configuration document before invoking the test
operation for each resource instance defined in the document. DSC then invokes the set operation
for each resource instance that isn't in the desired state.

The configuration document must be passed to this command as JSON or YAML over stdin.

## Examples

### Example 1 - Set a configuration's resource instances to the desired state

The command inspects the resource instances defined in the configuration document saved as
`example.dsc.config.yaml` and sets them to the desired state as needed.

```yaml
# example.dsc.config.yaml
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: Windows only
type: DSC/AssertionGroup
properties:
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Current user registry example
type: Microsoft.Windows/Registry
properties:
keyPath: HKCU\example
_ensure: Present
dependsOn:
- '[DSC/Assertion]Windows only'
```

```sh
cat ./example.dsc.config.yaml | dsc config set
```

## Options

### -h, --help

Displays the help for the current command or subcommand. When you specify this option, the
application ignores all options and arguments after this one.

```yaml
Type: Boolean
Mandatory: false
```

## Output

This command returns JSON output that includes whether the operation or any resources raised any
errors, the collection of messages emitted during the operation, and the set operation results for
every instance. For more information, see [dsc config get result schema][01].

[01]: ../../schemas/outputs/config/set.md
72 changes: 72 additions & 0 deletions docs/reference/cli/config/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# dsc config test

## Synopsis

Verifies whether the resource instances in a configuration document are in the desired state.

## Syntax

```sh
dsc config test [Options]
```

## Description

The `test` subcommand verifies whether the resource instances in a configuration document are in
the desired state. When this command runs, DSC validates the configuration document before invoking
the test operation for each resource instance defined in the document.

The configuration document must be passed to this command as JSON or YAML over stdin.

## Examples

### Example 1 - Test whether a configuration's resource instances are in the desired state

The command returns the status, desired state, actual state, and differing properties for the
resource instances defined in the configuration document saved as `example.dsc.config.yaml`.

```yaml
# example.dsc.config.yaml
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: Windows only
type: DSC/AssertionGroup
properties:
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Current user registry example
type: Microsoft.Windows/Registry
properties:
keyPath: HKCU\example
_ensure: Present
dependsOn:
- '[DSC/Assertion]Windows only'
```

```sh
cat ./example.dsc.config.yaml | dsc config test
```

## Options

### -h, --help

Displays the help for the current command or subcommand. When you specify this option, the
application ignores all options and arguments after this one.

```yaml
Type: Boolean
Mandatory: false
```

## Output

This command returns JSON output that includes whether the operation or any resources raised any
errors, the collection of messages emitted during the operation, and the test operation results for
every instance. For more information, see [dsc config test result schema][01].

[01]: ../../schemas/outputs/config/test.md
100 changes: 100 additions & 0 deletions docs/reference/cli/dsc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# dsc

## Synopsis

Apply configuration or invoke specific resources to manage software components.

## Syntax

```sh
dsc [Options] <COMMAND>
```

## Commands

### config

The `config` command manages a DSC Configuration document. You can use it to:

- Get the current state of the configuration.
- Test whether a configuration is in the desired state.
- Set a configuration to the desired state.

For more information, see [config][01].

### resource

The `resource` command manages a DSC Resource. You can use it to:

- List the available resources.
- Get the JSON schema for a resource's instances.
- Get the current state of a resource instance.
- Test whether a resource instance is in the desired state.
- Set a resource instance to the desired state.

For more information, see [resource][02]

### schema

The `schema` command returns the JSON schema for a specific DSC type. For more information, see
[schema][03].

### help

The `help` command returns help information for dsc, a command, or a subcommand.

To get the help for a command or subcommand, use the syntax:

```sh
dsc help <COMMAND> [<SUBCOMMAND>]
```

For example, `dsc help config` gets the help for the `config` subcommand. `dsc help config set`
gets the help for the `config set` subcommand.

You can also use the [--help](#h---help) option on a command to display the help information. For
example, `dsc config --help` or `dsc config set --help`.

## Options

### -f, --format

The `--format` option controls the console output format for the command. If the command output is
redirected or captured as a variable, the output is always JSON.

To set the output format for a command or subcommand, specify this option before the command, like
`dsc --format pretty-json resource list`.

```yaml
Type: String
Mandatory: false
Default Value: yaml
Valid Values:
- json
- pretty-json
- yaml
```

### -h, --help

Displays the help for the current command or subcommand. When you specify this option, the
application ignores all options and arguments after this one.

```yaml
Type: Boolean
Mandatory: false
```

### -V, --version

Displays the version of the application. When you specify this option, the application ignores all
options and arguments after this one.

```yaml
Type: Boolean
Mandatory: false
```

[01]: config.md
[02]: resource/command.md
[03]: schema.md
Loading