Files
PowerToys/src/modules/powerdisplay/PowerDisplay.Contracts/CliMessageIds.cs
moooyo 5c9c93d56d feat(powerdisplay): add CLI for monitor control (#48632)
## Summary of the Pull Request

Adds `PowerToys.PowerDisplay.Cli.exe`, a scriptable interface for
controlling monitors through the running PowerDisplay process. It
supports `list`, `get`, `set`, `up`, `down`, `capabilities`, `profiles`,
and `apply-profile`.

The CLI communicates over an authenticated, per-session named pipe;
PowerDisplay remains responsible for DDC/CI and WMI access.

## PR Checklist

- [x] Closes: #48713
- [x] **Communication:** Discussed with core contributors
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** Core errors are localizable; some help and
output text remains English-only
- [ ] **Dev docs:** N/A; built-in CLI help is the command reference
- [x] **New binaries:** Added on the required places
- [x] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
- [x] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetupVNext/Resources.wxs)
- [x] **YML for CI pipeline:** N/A; test assemblies are auto-discovered
- [x] **YML for signed pipeline:** N/A; signing is driven by
`ESRPSigning_core.json`
- [ ] **Documentation updated:** N/A

## Detailed Description of the Pull Request / Additional comments

- Adds an AOT-compatible CLI and shared request/response contracts.
- Uses a secured named-pipe server in PowerDisplay, with stable exit
codes and a bounded request timeout.
- Supports saved profiles by their existing stable profile IDs.
- Adds solution, signing, installer, and unit-test project integration.

## Validation Steps Performed

- PowerDisplay Lib, Contracts, CLI, and IPC unit-test suites pass.
- Native AOT publish completes without analyzer warnings.
- Manually validated the CLI on two DDC/CI monitors, including the
PowerDisplay-unavailable path.
- Rebuilt the PowerDisplay GUI after the shared-library changes.

---------

Co-authored-by: Yu Leng <yuleng@microsoft.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-16 23:08:27 +08:00

44 lines
2.0 KiB
C#

// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace PowerDisplay.Contracts;
/// <summary>
/// Stable, fine-grained identifiers for CLI error messages, shared by the app (which stamps one on
/// <see cref="CliError.MessageId"/>) and the CLI (which maps it to a localized template). Decoupled
/// from <see cref="CliErrorCodes"/>: several messages can share one coarse error code / exit code
/// (e.g. many are <see cref="CliErrorCodes.ArgumentError"/>). Never localized; never surfaced to users.
/// </summary>
public static class CliMessageIds
{
// set / common
public const string OutOfRange = "out-of-range";
public const string InvalidInteger = "invalid-integer";
public const string InvalidDiscrete = "invalid-discrete";
public const string DiscreteNotInSet = "discrete-not-in-set";
public const string InvalidOrientation = "invalid-orientation";
public const string Unsupported = "unsupported";
public const string PowerBlankingConfirm = "power-blanking-confirm";
public const string HardwareFailure = "hardware-failure";
// get / capabilities
public const string UnknownSetting = "unknown-setting";
public const string NotDiscreteSetting = "not-discrete-setting";
// monitor resolution
public const string SelectorMissing = "selector-missing";
public const string MonitorNotFoundNumber = "monitor-not-found-number";
public const string MonitorNotFoundId = "monitor-not-found-id";
// up / down
public const string UnknownSettingAdjust = "unknown-setting-adjust";
public const string NotAdjustable = "not-adjustable";
public const string AdjustValueUnknown = "adjust-value-unknown";
// profiles / internal
public const string ProfileNotFound = "profile-not-found";
public const string UnknownCommand = "unknown-command";
public const string InternalError = "internal-error";
}