Interactive debugger and REPL for Imba.
npm:
npm i -g imba-shellyarn:
yarn global add imba-shellTo start using imba-shell, run the following command:
imba-shellTo enable TypeScript, you can pass the --ts flag:
imba-shell --tsNote, you can also use
imbasinstead ofimba-shell.
To use multi-line mode, use the .editor command:
>>> .editorThis will open a multi-line editor.
When using multi-line mode, you can use the Shift+Tab key combination to indent the current line.
To remove a tab, use the Backspace key.
To clear the imba-shell, use the clear helper:
>>> clear!You can also use the
.clearcommand.
To exit out of imba-shell, use the exit helper:
>>> exit!You can also use the
.exitcommand.
You may use imba-shell as a runtime:
imbar file.imba
imbaraliases:imba-r,imba-runtime,ir.
Passing arguments to your script:
imbar craftsman.imba mail:send --helpContinously build and watch project (development purposes):
imbar --watch server.imbaflag:
--watch
alias:
-w
Creating a self executing script:
#!/usr/bin/env imbar
const name = process.argv.slice(2)[0] ?? 'stranger'
console.log "Hello {name}"If you're using Linux, FreeBSD or MacOS, you can make your script executable:
chmod u+x helloNote: when creating a script that doesn't end with
".imba", the Imba Runtime will clone your script into a hidden file that ends with.imbaand execute it instead of your original script. When done executing, the hidden file will be removed.
Running the script:
./hello Donald # Hello Donald
./hello # Hello strangerimba-shell can also be used as a module. Here's an example:
Imba:
import { ImbaRepl } from 'imba-shell'
# you can also pass "typescript" instead of "imba"
const repl = new ImbaRepl 'imba', 'imba> '
repl.run!JavaScript:
const { ImbaRepl } = require('imba-shell');
/** you can also pass "typescript" instead of "imba" */
const repl = new ImbaRepl('imba', 'imba> ');
repl.run();Note, you can pass an object of Node.js repl options in the
runfunction.
Here's an example of how to enable the history feature:
Imba:
import { ImbaRepl } from 'imba-shell'
import os from 'os'
import path from 'path'
const repl = new ImbaRepl 'imba', 'imba> ', path.join(os.homedir!, '.my_repl_history')
repl.run!JavaScript:
const { ImbaRepl } = require('imba-shell');
const os = require('os');
const path = require('path');
const repl = new ImbaRepl('imba', 'imba> ', path.join(os.homedir(), '.my_repl_history'));
repl.run();You can set any valid path as your history file.
You can register commands with the registerCommand function:
Imba:
repl.registerCommand 'goodbye', do
console.log 'Goodbye!'
this.close!JavaScript:
repl.registerCommand('goodbye', () => {
console.log('Goodbye!');
this.close();
});You may register functions and properties to be available in the REPL using the registerCallback function:
Imba:
const repl = new ImbaRepl
repl.registerCallback do(ctx)
ctx.foo = 'bar'JavaScript:
const repl = new ImbaRepl();
repl.registerCallback((ctx) => {
ctx.foo = 'bar'
})When calling foo in the REPL, it will return bar.
- Language Support.
- Imba.
- TypeScript.
- Code completion.
- Imba.
- TypeScript.
- Multiline Editor.
- Imba.
- TypeScript.
- Async/Await.
- Imba.
- TypeScript.
- Extensible API.
- Syntax highlighting.
- Imba.
- TypeScript.
- Compile Errors.
- Imba.
- TypeScript.
Install dependencies:
$ npm iBuild from source:
$ npm run buildTest Imba-Shell:
$ npm run testIf you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.