Skip to content

Commit dbfdd0f

Browse files
committed
Merge branch 'develop' of https://github.com/easterapps/script-runner into develop
2 parents 432589e + 2c126f9 commit dbfdd0f

6 files changed

Lines changed: 96 additions & 38 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ jobs:
2727
- run: npm install
2828
- run: npm ci
2929
- run: npm run compile
30-
- name: Get tag name
31-
uses: olegtarasov/get-tag@v2
3230
- name: "Publish to Marketplace"
3331
uses: lannonbr/vsce-action@master
3432
with:
@@ -38,7 +36,7 @@ jobs:
3836
- name: "Package release"
3937
uses: lannonbr/vsce-action@master
4038
with:
41-
args: "package $GIT_TAG_NAME"
39+
args: "package"
4240
env:
4341
VSCE_TOKEN: ${{ secrets.vsce_token }}
4442
- name: Upload binaries to release

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@ Sample command definition:
7272
}
7373
```
7474

75-
| Name | Description | Required | Type |
76-
| ------------------- | ----------------------------------------------------------------------------------- | -------- | ------- |
77-
| `identifier` | Identifier used to do key binding. Use alphanumerical and hyphen/underscore only. | yes | string |
78-
| `description` | Description of the command. | yes | string |
79-
| `command` | Command to execute (with variables). | yes | string |
80-
| `working_directory` | The working directory in which to execute the script. | | string |
81-
| `form` | A list of questions to ask in order to obtain values for variables. | | array |
82-
| `variable` | The variable name. | | string |
83-
| `question` | The question to ask the user. | |
84-
| `password` | Input is a password. Default is false. Suggestion: use also show_in_console: false | | boolean |
85-
| `default` | The default value to put in the field. Only for text inputs. | | string |
86-
| `options` | List of options (string) | | array |
87-
| `variables` | List of variables (string) | | array |
75+
| Name | Description | Required | Type |
76+
| ---------------------- | ------------------------------------------------------------------------------------------------------ | -------- | ------- |
77+
| `identifier` | Identifier used to do key binding. Use alphanumerical and hyphen/underscore only. | yes | string |
78+
| `description` | Description of the command. | yes | string |
79+
| `command` | Command to execute (with variables). | yes | string |
80+
| `working_directory` | The working directory in which to execute the script. | | string |
81+
| `form` | A list of questions to ask in order to obtain values for variables. | | array |
82+
| `variable` | The variable name. | | string |
83+
| `question` | The question to ask the user. | | string |
84+
| `password` | Input is a password. Default is false. Suggestion: use also show_in_console: false | | boolean |
85+
| `default` | The default value to put in the field. Only for text inputs. | | string |
86+
| `defaultValuePath` | Overrides the default value with the current file path. Empty if no file open. password option ignored | | boolean |
87+
| `defaultValueFilename` | Overrides the default value with the current filename. Empty if no file open. password option ignored | | boolean |
88+
| `options` | List of options (string) | | array |
89+
| `variables` | List of variables (string) | | array |
8890

8991
## Full Configuration Sample
9092

@@ -126,6 +128,19 @@ Sample command definition:
126128
"default": "Test 1"
127129
}
128130
]
131+
},
132+
{
133+
"identifier": "filepath1",
134+
"description": "Filepath",
135+
"command": "echo $path ",
136+
"working_directory": "$tmp",
137+
"form": [
138+
{
139+
"variable": "$path",
140+
"question": "What is the path",
141+
"defaultValuePath": true
142+
}
143+
]
129144
}
130145
],
131146
"variables": {

package-lock.json

Lines changed: 23 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Script Runner",
44
"description": "Run command line scripts (with parameters) directly from #VSCode with a configured form. Create and customize your own commands to simplify your way of working.",
55
"icon": "resources/logo/icon_128.gif",
6-
"version": "0.5.0",
6+
"version": "0.6.0",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/easterapps/vscode-script-runner"
@@ -120,6 +120,16 @@
120120
"items": {
121121
"type": "string"
122122
}
123+
},
124+
"defaultValuePath": {
125+
"type": "boolean",
126+
"description": "The default value to put in the field. Only for text inputs.",
127+
"default": false
128+
},
129+
"defaultValueFilename": {
130+
"type": "boolean",
131+
"description": "The default value to put in the field. Only for text inputs.",
132+
"default": false
123133
}
124134
}
125135
}

src/command_runner.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { workspace, window, OutputChannel, TerminalOptions } from "vscode";
33
import { IConfiguration, ICommandConfiguration, IFormConfiguration } from "./configuration";
44
import { VariableManager } from "./variable_manager";
55
import { Terminal } from "./terminal";
6+
var path = require("path");
7+
var vscode = require("vscode");
68

79
export class CommandRunner {
810
private outputChannel: OutputChannel;
@@ -61,6 +63,14 @@ export class CommandRunner {
6163
if (form && form.length > 0) {
6264
let currentStep = 0;
6365
const firstStep = form[currentStep];
66+
let currentlyOpenTabfilePath = ""
67+
let currentlyOpenTabfileName = ""
68+
try {
69+
currentlyOpenTabfilePath = vscode.window.activeTextEditor.document.fileName;
70+
currentlyOpenTabfileName = path.basename(currentlyOpenTabfilePath);
71+
} catch (error) {
72+
73+
}
6474

6575
const askQuestion = (step: IFormConfiguration) => {
6676
if (step.options) {
@@ -69,13 +79,27 @@ export class CommandRunner {
6979
ignoreFocusOut: true,
7080
});
7181
} else {
72-
73-
return window.showInputBox({
74-
prompt: step.question,
75-
value: step.default,
76-
password: step.password,
77-
ignoreFocusOut: true,
78-
});
82+
if (step.defaultValuePath) {
83+
return window.showInputBox({
84+
prompt: step.question,
85+
value: currentlyOpenTabfilePath,
86+
ignoreFocusOut: true,
87+
});
88+
} else {
89+
if (step.defaultValueFilename) {
90+
return window.showInputBox({
91+
prompt: step.question,
92+
value: currentlyOpenTabfileName,
93+
ignoreFocusOut: true,
94+
});
95+
}
96+
return window.showInputBox({
97+
prompt: step.question,
98+
value: step.default,
99+
password: step.password,
100+
ignoreFocusOut: true,
101+
});
102+
}
79103
}
80104
};
81105

src/configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface IFormConfiguration {
1818
default?: string;
1919
password?: boolean;
2020
options?: string[];
21+
defaultValuePath?: boolean;
22+
defaultValueFilename?: boolean;
2123
}
2224

2325
export type IVariableConfiguration = { [id: string]: string };

0 commit comments

Comments
 (0)