Skip to content

CLI parameters and subcommands #984

@ThomasNieto

Description

@ThomasNieto

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

When building and testing commands it is natural to append --trace-level or any other parameter that is for the subcommand or a child of said subcommand. This does not work like other CLI applications. The parameters are only valid in the same order as the command/subcommand.

Take the following command, I ran the command without tracing and now would like to add tracing to the end of the command. This command fails. However if you put it at the very beginning it works.

#fails 
dsc config get -f C:\temp\Test.dsc.yaml --trace-level trace
dsc config get --trace-level trace -f C:\temp\Test.dsc.yaml
dsc config --trace-level trace -f get C:\temp\Test.dsc.yaml

# works
dsc --trace-level trace config -f get C:\temp\Test.dsc.yaml

Steps to reproduce

PS C:\> dsc config get -f C:\temp\Test.dsc.yaml
metadata:
  Microsoft.DSC:
    version: 3.1.0
    operation: get
    executionType: actual
    startDatetime: 2025-07-20T00:18:53.188218700-05:00
    endDatetime: 2025-07-20T00:18:53.381591700-05:00
    duration: PT0.193373S
    securityContext: restricted
results:
- metadata:
    Microsoft.DSC:
      duration: PT0.0206813S
  name: current user registry
  type: Microsoft.Windows/Registry
  result:
    actualState:
      keyPath: HKCU\test
      valueName: pizza
      _exist: false
messages: []
hadErrors: false
PS C:\> dsc config get -f C:\temp\Test.dsc.yaml --trace-level trace
error: unexpected argument '--trace-level' found

Usage: dsc.exe config get --file <FILE>

For more information, try '--help'

Expected behavior

dsc config get -f C:\temp\Test.dsc.yaml --trace-level trace

works

Actual behavior

error: unexpected argument '--trace-level' found

Usage: dsc.exe config get --file <FILE>

For more information, try '--help'

Error details

Environment data

7.5-preview4

Version

3.2-preview2

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions