Skip to content

Commit

Permalink
v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bayaraa committed Oct 22, 2024
1 parent 527227a commit 41e1a59
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 142 deletions.
50 changes: 36 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
VSERunOnSave
========================
This **Visual Studio Extension** enables run **VS** command or external command on before/after save event of currently editing file.
This **Visual Studio Extension** enables call **VS** commands or external commands on before/after save event of the file currently being edited.
Supports Visual Studio 2022 x64/arm64 platforms.

## Configuration
In order to run extension you need to create `.vserunonsave` configuration file in your solition or project root directory.
In order to work this extension, you need to create `.vserunonsave` configuration file in your solution or project root directory.
Each section may have following config lines:
- `vs_command_before` vs commands to run right before save.
- `vs_command_after` vs commands to run right after save.
- `ext_command_before` external command to call right before save.
- `ext_command_after` external command to call right after save.
- `output_string` simple message to display into output pane after all commands runs.
- `vs_command_before` VS commands to run right before the document is saved.
- `vs_command_after` VS commands to run right after the document is saved.
- `ext_command_before` External commands to call right before the document is saved.
- `ext_command_after` External commands to call right after the document is saved.
- `ext_command_timeout` Timeout setting for each external commands in seconds.
- `output_clear` Clear the output pane before all commands run.
- `output_start` A string to display in the output pane before all commands run.
- `output_end` A string to display in the output pane after all commands run.
- ~~`output_string` simple message to display into output pane after all commands runs.~~ **Removed. Use:`output_end`*

**You can enter comma separated multiple commands.*
**All config are optional.*

Built in variabled automatically replaced:
- `$(File)` Full path of currently editing file.
- `$(FileDir)` Directory of currently editing file (without trailing `\`).
- `$(FileName)` File name of currently editing file.
- `$(FileNameNoExt)` File name of currently editing file (without extension).
Automatically replaced built-in variables:
- `$(File)` Full path of the file currently being edited.
- `$(FileDir)` Directory of the file currently being edited (without trailing `\`).
- `$(FileName)` File name of the file currently being edited.
- `$(FileNameNoExt)` File name of the file currently being edited (without extension).
- `$(ProjectDir)` Project directory (without trailing `\`).
- `$(SolutionDir)` Solution directory (without trailing `\`).
- `$(Configuration)` Current project's build configuration name (ex: Release/Debug etc).
- `$(Platform)` Current project's build platform name (ex: x64/Win32/arm64 etc).
- `$(time)` Current time (format: HH:mm:ss).
- `$(nl)` New line character (Useful when you output multiline string).

## Examples
Ex: Any c/c++ source/header files to automatically formatted upon save:
Expand All @@ -34,14 +42,28 @@ Ex: sample.cs file to automatically formatted and all it's contents copied to cl
[sample.cs]
vs_command_before = Edit.FormatDocument
vs_command_after = Edit.SelectAll, Edit.Copy
output_string = Contents copied to clipboard!
output_end = Contents copied to clipboard!
```
Ex: Compile fragment shader file and save with different name:
```ini
[*.frag]
ext_command_after = "$(SolutionDir)\tools\glslangValidator.exe" -s -V "$(File)" -o "$(FileDir)\spir-v\$(FileNameNoExt).spv"
output_string = Compiled: $(FileNameNoExt).spv
ext_command_timeout = 30
output_end = Compiled: $(FileNameNoExt).spv
output_clear = true
```

## Credits
Inspired by [VSE-FormatDocumentOnSave](https://github.com/Elders/VSE-FormatDocumentOnSave) extension by mynkow.

## Change Log
### 1.1.2
- Overall code refator.
- Added: Configs `ext_command_timeout` `output_clear` `output_start`.
- Added: Variables `$(Configuration)` `$(Platform)` `$(time)` `$(nl)`.
- Added: Slow commands can block VS until they finish. Now you can use `ext_command_timeout` to break.
- Changed: Config `output_string` replaced with `output_end`.
- Changed: now output pane not cleared after all commands run. Have to set `output_clear` to clear pane.

### 1.0.0
Initial release.
Loading

0 comments on commit 41e1a59

Please sign in to comment.