Create a general solution for warnings before command execution

[?]
Jan 7, 2021, 1:46 AM
BOCCATU2STQRXDDXKEIEFYIHFONOJYZM457UEPBKD7HQPFYA75IAC

Dependencies

  • [2] UBNZ7UMT Add warning message to the resetAll command
  • [3] 5ISTB4TW Add commands to copy the hash and message of changes in the log
  • [4] 6H4B4UJQ Add commands to open repo and global pijul configuration files
  • [5] GNQD74OZ Add pijul.openChange command and text document provider for pijul-change scheme
  • [6] VWRDBPJZ Add command and menu option for adding one or more files to the repository
  • [7] L44OILGK Add reset command to resource state context menu
  • [8] MU6ZNUYZ Integrate recordAll command with input box
  • [9] YDCLFNEJ Add menu command for recording changes to specific files
  • [*] ILH3GIVT Add command centre and refresh/init commands

Change contents

  • replacement in src/commands.ts at line 198
    [4.925][4.2150:2197](),[4.1246][4.2150:2197]()
    await repository.reset(...resourceStates);
    [4.925]
    [4.1596]
    if (await commandWarning(`Are you sure you want to reset ${resourceStates.length} file(s) to their last recorded state? Any changes will be lost forever.`)) {
    await repository.reset(...resourceStates);
    await repository.refreshStatus();
    }
  • replacement in src/commands.ts at line 210
    [4.1838][2.0:314]()
    const message = `Are you sure you want to reset ${this.repository.changedGroup.resourceStates.length} file(s) to their last recorded state? Any changes will be lost forever.`;
    const yes = 'Continue';
    const pick = await window.showWarningMessage(message, { modal: true }, yes);
    if (pick === yes) {
    [4.1838]
    [2.314]
    if (await commandWarning(`Are you sure you want to reset ${this.repository.changedGroup.resourceStates.length} file(s) to their last recorded state? Any changes will be lost forever.`)) {
  • replacement in src/commands.ts at line 241
    [4.1381][3.120:159]()
    * @param change The change top open
    [4.1381]
    [4.1430]
    * @param change The change to open
  • edit in src/commands.ts at line 345
    [11.4046]
    [11.4046]
    }
    /**
    * Show a warning message to the user before executing a command.
    * @param message The message to display on the warning message.
    * @returns A boolean indicating if command execution should continue
    */
    async function commandWarning (message: string): Promise<boolean> {
    const yes = 'Continue';
    const pick = await window.showWarningMessage(message, { modal: true }, yes);
    return pick === yes;