npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imba-shell

v0.5.1

Published

Interactive debugger and REPL for Imba.

Downloads

184

Readme

Imba Shell

Status npm GitHub

Interactive debugger and REPL for Imba.

imba-shell

Install

npm:

npm i -g imba-shell

yarn:

yarn global add imba-shell

Usage

To start using imba-shell, run the following command:

imba-shell

To enable TypeScript, you can pass the --ts flag:

imba-shell --ts

Note, you can also use imbas instead of imba-shell.

Multiline

To use multi-line mode, use the .editor command:

>>> .editor

This will open a multi-line editor.

Indentation

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.

Clear

To clear the imba-shell, use the clear helper:

>>> clear!

You can also use the .clear command.

Exit

To exit out of imba-shell, use the exit helper:

>>> exit!

You can also use the .exit command.

Imba Runtime

You may use imba-shell as a runtime:

imbar file.imba

imbar aliases: imba-r, imba-runtime, ir .

Passing arguments to your script:

imbar craftsman.imba mail:send --help

Continously build and watch project (development purposes):

imbar --watch server.imba

flag: --watch

alias: -w

Creating a self executing script:

hello

#!/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 hello

Note: when creating a script that doesn't end with ".imba", the Imba Runtime will clone your script into a hidden file that ends with .imba and 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 stranger

API

imba-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 run function.

History

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.

Commands

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();
});

Context

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.

Todo

  • [x] Language Support.
    • [x] Imba.
    • [x] TypeScript.
  • [x] Code completion.
    • [x] Imba.
    • [x] TypeScript.
  • [x] Multiline Editor.
    • [x] Imba.
    • [x] TypeScript.
  • [x] Async/Await.
    • [x] Imba.
    • [x] TypeScript.
  • [x] Extensible API.
  • [ ] Syntax highlighting.
    • [ ] Imba.
    • [ ] TypeScript.
  • [ ] Compile Errors.
    • [ ] Imba.
    • [x] TypeScript.

Development

Install

Install dependencies:

$ npm i

Build

Build from source:

$ npm run build

Test

Test Imba-Shell:

$ npm run test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.