-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: a new dedicated execute command for the R Shell to allow also m…
…ore declarative execution :D
- Loading branch information
1 parent
c1f9fe3
commit 0ddce3b
Showing
3 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { RShell } from '../../../r-bridge' | ||
import { italic } from '../../../statistics' | ||
import { ReplCommand } from './main' | ||
|
||
|
||
export async function executeRShellCommand(shell: RShell, statement: string) { | ||
try { | ||
const result = await shell.sendCommandWithOutput(statement, { | ||
from: 'both', | ||
automaticallyTrimOutput: true | ||
}) | ||
console.log(`${italic(result.join('\n'))}\n`) | ||
} catch(e) { | ||
console.error(`Error while executing '${statement}': ${(e as Error).message}`) | ||
} | ||
} | ||
|
||
|
||
export const executeCommand: ReplCommand = { | ||
description: 'Execute the given code as R code (essentially similar to using now command)', | ||
usageExample: ':execute', | ||
aliases: [ 'e', 'r' ], | ||
script: false, | ||
fn: async(shell, _tokenMap, remainingLine) => { | ||
await executeRShellCommand(shell, remainingLine) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters