Imba 用の対話型デバッガーと REPL。
npm:
npm i -g imba-shell
糸:
yarn global add imba-shell
imba-shell
使用を開始するには、次のコマンドを実行します。
imba-shell
TypeScript を有効にするには、 --ts
フラグを渡します。
imba-shell --ts
imba-shell
代わりにimbas
使用することもできることに注意してください。
複数行モードを使用するには、.editor コマンドを使用します。
>>> .editor
これにより、複数行エディタが開きます。
複数行モードを使用する場合、 Shift+Tab
キーの組み合わせを使用して現在の行をインデントできます。
タブを削除するには、 Backspace
キーを使用します。
imba-shell
クリアするには、 clear
ヘルパーを使用します。
>>> clear !
.clear
コマンドを使用することもできます。
imba-shell
を終了するには、 exit
ヘルパーを使用します。
>>> exit !
.exit
コマンドを使用することもできます。
imba-shell
ランタイムとして使用できます。
imbar file.imba
imbar
エイリアス:imba-r
、imba-runtime
、ir
。
スクリプトに引数を渡す:
imbar craftsman.imba mail:send --help
プロジェクトを継続的に構築して監視します (開発目的):
imbar --watch server.imba
フラグ:
--watch
別名:
-w
自己実行スクリプトの作成:
hello
#!/usr/bin/env imbar
const name = process . argv . slice ( 2 )[ 0 ] ?? 'stranger'
console . log "Hello {name}"
Linux
、 FreeBSD
、またはMacOS
使用している場合は、スクリプトを実行可能にすることができます。
chmod u+x hello
注:
".imba"
で終わらないスクリプトを作成すると、Imba ランタイムはスクリプトを.imba
で終わる隠しファイルに複製し、元のスクリプトの代わりに実行します。実行が完了すると、隠しファイルは削除されます。
スクリプトの実行:
./hello Donald # Hello Donald
./hello # Hello stranger
imba-shell
モジュールとしても使用できます。以下に例を示します。
インバ:
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 ( ) ;
run
関数で Node.js repl オプションのオブジェクトを渡すことができることに注意してください。
履歴機能を有効にする方法の例を次に示します。
インバ:
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 ( ) ;
任意の有効なパスを履歴ファイルとして設定できます。
registerCommand
関数を使用してコマンドを登録できます。
インバ:
repl . registerCommand 'goodbye' , do
console . log 'Goodbye!'
this . close !
JavaScript:
repl . registerCommand ( 'goodbye' , () = > {
console . log ( 'Goodbye!' );
this . close ();
});
registerCallback
関数を使用して、REPL で使用できる関数とプロパティを登録できます。
インバ:
const repl = new ImbaRepl
repl . registerCallback do ( ctx )
ctx . foo = 'bar'
JavaScript:
const repl = new ImbaRepl ( ) ;
repl . registerCallback ( ( ctx ) => {
ctx . foo = 'bar'
} )
REPL でfoo
呼び出すと、 bar
返されます。
依存関係をインストールします。
$ npm i
ソースからビルドする:
$ npm run build
Imba-Shell
をテストします。
$ npm run test
セキュリティ関連の問題を発見した場合は、問題トラッカーを使用する代わりに、[email protected] に電子メールを送信してください。
MIT ライセンス (MIT)。詳細については、ライセンス ファイルを参照してください。