Skip to content

Commit

Permalink
feat: add run to from begin to current entry
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Oct 16, 2024
1 parent 252fa08 commit 5c15581
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 103 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@

<!-- commands -->

| Command | Title |
| ------------------------------------------ | ------------------------------------ |
| `vscode-hurl-runner.runHurl` | Hurl Runner: Run at entry |
| `vscode-hurl-runner.runHurlFile` | Hurl Runner: Run File |
| `vscode-hurl-runner.runHurlToEnd` | Hurl Runner: Run to End |
| `vscode-hurl-runner.manageInlineVariables` | Hurl Runner: Manage Inline Variables |
| `vscode-hurl-runner.selectEnvFile` | Hurl Runner: Select Environment File |
| `vscode-hurl-runner.runHurlSelection` | Hurl Runner: Run Selected Text |
| `vscode-hurl-runner.rerunLastCommand` | Hurl Runner: Rerun Last Command |
| Command | Title |
| ------------------------------------------ | -------------------------------------- |
| `vscode-hurl-runner.runHurl` | Hurl Runner: Run at entry |
| `vscode-hurl-runner.runHurlFile` | Hurl Runner: Run File |
| `vscode-hurl-runner.runHurlToEnd` | Hurl Runner: Run to End |
| `vscode-hurl-runner.manageInlineVariables` | Hurl Runner: Manage Inline Variables |
| `vscode-hurl-runner.selectEnvFile` | Hurl Runner: Select Environment File |
| `vscode-hurl-runner.runHurlSelection` | Hurl Runner: Run Selected Text |
| `vscode-hurl-runner.rerunLastCommand` | Hurl Runner: Rerun Last Command |
| `vscode-hurl-runner.runHurlFromBegin` | Hurl Runner: Run from Begin to Current |

<!-- commands -->

Expand Down
189 changes: 95 additions & 94 deletions cspell-tool.txt
Original file line number Diff line number Diff line change
@@ -1,120 +1,121 @@
Huynh
jellydn
bumpp
esno
antfu
anymatch
argparse
asynckit
automerge
biomejs
tsup
vite
vitest
esbuild
loong
riscv
sunos
isaacs
jridgewell
jsdevtools
nodelib
pkgjs
rollup
magicast
picomatch
jiti
iojs
lightningcss
sugarss
jsdom
msal
jsonwebtoken
scandir
fastq
undici
tinyrainbow
estree
pathe
tinyspy
minimatch
yauzl
yazl
keytar
boolbase
bumpp
buymeacoffee
chokidar
chownr
citty
cliui
confbox
consola
defu
dotenv
giget
mlly
ohash
pathval
boolbase
destr
domelementtype
domhandler
domutils
htmlparser
anymatch
readdirp
dotenv
eabi
eastasianwidth
esbuild
esno
estree
execa
extglob
fastq
fdir
fsevents
consola
fullwidth
giget
gnueabihf
gopd
reusify
asynckit
minipass
hasown
citty
nypm
jackspeak
extglob
cliui
parseargs
argparse
htmlparser
Huynh
iojs
isaacs
isboolean
isexe
isinteger
isnumber
isplainobject
prebuild
yallist
jackspeak
jellydn
jiti
joycon
jridgewell
jsdevtools
jsdom
jsonwebtoken
keytar
kleur
kofi
libc
lightningcss
lilconfig
linkify
loong
magicast
mdurl
thenify
execa
wrappy
lilconfig
picocolors
libc
microtask
minimatch
minimist
minipass
minizlib
mkdirp
mlly
msal
msvc
musleabihf
namelookup
napi
kleur
nodelib
nvim
nypm
ohash
parseargs
pathe
pathval
pfeiferj
picocolors
picomatch
pkgjs
prebuild
readdirp
registed
reusify
riscv
rollup
scandir
scule
siginfo
sisteransi
destr
eabi
gnueabihf
musleabihf
msvc
microtask
whatwg
fullwidth
eastasianwidth
chownr
minizlib
fdir
joycon
tinyglobby
sortby
stackback
sugarss
sunos
thenify
tinybench
tinyexec
tinyglobby
tinypool
scule
yargs
sortby
tinyrainbow
tinyspy
tsup
typecheck
undici
Verseth
vite
vitest
webidl
isexe
siginfo
stackback
whatwg
wrappy
xmlbuilder
nvim
pfeiferj
Verseth
kofi
buymeacoffee
automerge
registed
namelookup
yallist
yargs
yauzl
yazl
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
{
"command": "vscode-hurl-runner.rerunLastCommand",
"title": "Hurl Runner: Rerun Last Command"
},
{
"command": "vscode-hurl-runner.runHurlFromBegin",
"title": "Hurl Runner: Run from Begin to Current"
}
],
"viewsContainers": {
Expand Down Expand Up @@ -145,6 +149,12 @@
"key": "ctrl+alt+shift+r",
"mac": "cmd+alt+shift+r",
"when": "editorTextFocus && editorLangId == hurl"
},
{
"command": "vscode-hurl-runner.runHurlFromBegin",
"key": "ctrl+alt+shift+b",
"mac": "cmd+alt+shift+b",
"when": "editorTextFocus && editorLangId == hurl"
}
],
"languages": [
Expand Down
53 changes: 53 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,59 @@ const { activate, deactivate } = defineExtension(() => {
}
});

// Run hurl from begin to current entry
useCommand(commands.runHurlFromBegin, async () => {
const runHurlFromBeginCommand = async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
showResultInWebView({ stdout: "", stderr: "No active editor" }, true);
return;
}

showLoadingInWebView();

const filePath = editor.document.uri.fsPath;
const currentLine = editor.selection.active.line + 1;
const fileContent = editor.document.getText();

try {
const currentEntry = findEntryAtLine(fileContent, currentLine);
if (!currentEntry) {
showResultInWebView(
{ stdout: "", stderr: "No Hurl entry found at the current line" },
true,
);
return;
}

// Store the last command info
lastCommandInfo = {
command: runHurlFromBeginCommand,
filePath,
entryNumber: currentEntry.entryNumber,
};

const envFile = envFileMapping[filePath];
const variables = hurlVariablesProvider.getAllVariablesBy(filePath);

const result = await executeHurl({
filePath,
envFile,
variables,
fromEntry: 1,
toEntry: currentEntry.entryNumber,
});

showResultInWebView(result);
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Unknown error";
showResultInWebView({ stdout: "", stderr: errorMessage }, true);
}
};
await runHurlFromBeginCommand();
});

return {
dispose: () => {
if (resultPanel) {
Expand Down

0 comments on commit 5c15581

Please sign in to comment.