Skip to content

Commit

Permalink
Merge pull request #64 from ryuta46/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuta46 authored Jul 11, 2022
2 parents 8d0b755 + a19a357 commit 8ae5c41
Show file tree
Hide file tree
Showing 8 changed files with 844 additions and 59 deletions.
26 changes: 18 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,33 @@

// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
"version": "2.0.0",

// we want to run npm
"command": "npm",

// the command is a shell script
"isShellCommand": true,

// show the output window only if unrecognized errors occur.
"showOutput": "silent",

// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],

// The tsc compiler is started in watching mode
"isWatching": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
"problemMatcher": "$tsc-watch",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "npm",
"args": [
"run",
"compile",
"--loglevel",
"silent"
],
"isBackground": true,
"problemMatcher": "$tsc-watch",
"group": "build"
}
]
}
38 changes: 34 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
# Change Log
All notable changes to the "multi-command" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## 1.6.0
### Added
- [Variable substitution like `${userHome}` or `${config:editor.fontSize}` in arguments.](/README.md#pass-arguments-to-commands)
- [Conditioned commands to branch a sequence when a command fails.](/README.md#conditioned-commands)
- [Parameter to repeat a command.](/README.md#repeat-commands)
- [Language filter for manual execution.](/README.md#manual-execution)

## [Unreleased]
- Initial release
## 1.5.1
### Added
- Support extensionKind ui or workspace.

## 1.5.0
### Added
- Simple usage only with keybindings.json
- Object style settings for merging user settings and workspace settings.

## 1.4.0
### Added
- New style for binding a key to created commands.

## 1.3.0
### Added
- Manual execution from command palette.

## 1.2.0
### Added
- Pass arguments to commands.

## 1.1.0
### Fixed
- Reloads settings.json when the file is changed.
Now, you can use a custom multi-command immediately after adding it in the settings.json without restarting vscode.

## 1.0.0
Initial release.
156 changes: 125 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This command sequence executes "cursorDown" command 3 times.

### Usage with settings.json.

This usage is useful for resusing the defined command sequence in another command sequnce or executing the sequence manually.
This usage is useful for reusing the defined command sequence in another command sequnce or executing the sequence manually.

In case using settings.json, the settings has 2 steps.

Expand Down Expand Up @@ -157,6 +157,22 @@ For example:
},
```

If you set `languages` parameter in settings.json, the sequence is displayed only when a document of specified language is opened.
For example:

```json
"multiCommand.commands": [
{
"command": "multiCommand.eslint",
"sequence": [
"eslint.executeAutofix",
],
"languages": ["javascript", "typescript"]
},
]
```
`multiCommand.eslint` is displayed only when the opened document is JavaScript or TypeScript.

### Advanced Settings

#### Pass arguments to commands
Expand All @@ -176,6 +192,114 @@ For Example:

This sequence cut selected text and type "CUT !!".

You can also use some variables like `${userHome}` or `${config:editor.fontSize}` in arguments.

Because some commands substitute these kinds of variables in their extensions, variable substitution in multi-command extenstion is kind of experimental.

If you use variable substituion, set `variableSubstitution` to `true` in command setting.

For example:
```json
"sequence": [
{
"command": "type",
"args": { "text": "Font size is ${config:editor.fontSize}" },
"variableSubstitution": true
}
],
```

Current supported variables:

* `${userHome}`
* `${workspaceFolder}`
* `${workspaceFolderBasename}`
* `${file}`
* `${fileWorkspaceFolder}`
* `${relativeFile}`
* `${relativeFileDirname}`
* `${fileBasename}`
* `${fileBasenameNoExtension}`
* `${fileDirname}`
* `${fileExtname}`
* `${cwd}`
* `${lineNumber}`
* `${selectedText}`
* `${pathSeparator}`
* `${env:*}`
* `${config:*}`

Contents of each variable are described in [variables reference in VSCode](https://code.visualstudio.com/docs/editor/variables-reference). Note that all variables in the document is not supported in multi-command extension.

#### Repeat commands

The above `multiCommand.down3Lines` sample also written as follows by using `repeat` field:

```json
{
"command": "multiCommand.down3Lines",
"label": "down3Lines",
"description": "down the cursor in 3 times",
"sequence": [
{ "command": "cursorDown", "repeat": 3 }
],
}
```
You can also repeat a sequence by using `extension.multiCommand.execute` or defined command in settings.json.

```json
{
"sequence": [
{
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.commentLine",
"cursorDown"
]
},
"repeat": 5
}
],
}
```

This sequence add line comment to next 5 lines.

#### Conditioned commands

A sequence can be branched by the result of whether or not a given command terminated with an error.
This feature is useful when you are not sure if an extension is installed or not. You can use an alternative command if the extension is not installed.

For example:
```json
{
"sequence": [
"eslint.executeAutofix || editor.action.formatDocument"
]
}
```

Only when `eslint.executeAutofix` finished with an error like command not found, `editor.action.formatDocument` is invoked.
Note that there must be at least one space on each side of the `||` operator.

For more complex command like passing arguments, use `onFail` field.
```json
"sequence": [
{
"command": "A",
"onFail": [
"B",
{
"command": "C",
"args": { "arg": "argumentForC" }
},
]
}
]
```
Only when command A finished with an error, command B and command C with arguments are invoked.

### Find the name of the command you want to execute

1. Execute "Developer: Set Log Level..." and select "trace" in the command palette.
Expand Down Expand Up @@ -204,33 +328,3 @@ With Command Runner extension, you can write a command sequence with shell comma
```

See the [Command Runner document](https://marketplace.visualstudio.com/items?itemName=edonet.vscode-command-runner) for details on how to use the extension.

## Release Notes

### 1.5.1
Support extensionKind ui or workspace.

### 1.5.0
New Feature: Simple usage only with keybindings.json
New Feature: Object style settings for merging user settings and workspace settings.

### 1.4.0

Added new style for binding a key to created commands.

### 1.3.0

New Feature: Manual execution from command palette.

### 1.2.0

New Feature: Pass arguments to commands.

### 1.1.0

Reloads settings.json when the file is changed.
Now, you can use a custom multi-command immediately after adding it in the settings.json without restarting vscode.

### 1.0.0

Initial release.
Loading

0 comments on commit 8ae5c41

Please sign in to comment.