@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
43 lines (42 loc) • 1.83 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatDocumentCommand = exports.FormatDocumentCommand = void 0;
const IToolCommand_1 = require("../IToolCommand");
class FormatDocumentCommand extends IToolCommand_1.ToolCommandBase {
metadata = {
name: "format",
description: "Explain how document formatting works and how to enable format-on-save",
aliases: ["fmt"],
category: "General",
isWriteCommand: false,
examples: ["/format", "/fmt"],
};
async execute(context, _args, _flags) {
const lines = [
"Format-on-save is OFF by default — your raw JSON / TS files are saved exactly as you typed them.",
"Switching from Raw mode back to a visual editor (Focused or Full) will reformat the document automatically.",
"To re-enable format-on-save for ALL saves: open the Settings panel and toggle 'Format documents before saving' ON.",
];
let formatBeforeSave;
if (context.creatorTools) {
try {
formatBeforeSave = context.creatorTools.formatBeforeSave;
lines.push(`Current setting: formatBeforeSave = ${formatBeforeSave ? "on" : "off"}.`);
}
catch {
// ignore — settings access is best-effort here
}
}
for (const line of lines) {
context.output.info(line);
}
return this.success("Displayed formatting guidance", {
formatBeforeSave,
hint: "Settings panel → Format documents before saving",
});
}
}
exports.FormatDocumentCommand = FormatDocumentCommand;
exports.formatDocumentCommand = new FormatDocumentCommand();