mirror of
https://github.com/samsonjs/repl-edit.git
synced 2026-04-27 15:07:40 +00:00
s/edit-repl/repl-edit/ and fleshed out readme a bit
This commit is contained in:
parent
7fe609bd61
commit
6b5cb82723
4 changed files with 82 additions and 10 deletions
2
LICENSE
2
LICENSE
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright 2009, 2010 Sami Samhuri. All rights reserved.
|
Copyright 2010 Sami Samhuri. All rights reserved.
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to
|
of this software and associated documentation files (the "Software"), to
|
||||||
deal in the Software without restriction, including without limitation the
|
deal in the Software without restriction, including without limitation the
|
||||||
|
|
|
||||||
73
Readme.md
73
Readme.md
|
|
@ -1 +1,72 @@
|
||||||
TODO
|
repl-edit
|
||||||
|
=========
|
||||||
|
|
||||||
|
Use your text editor to edit commands in Node's repl.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
npm install repl-edit
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
You can fire up a repl with editing capabilities by running `node-repl-edit`
|
||||||
|
or extend an existing repl session by typing `require('repl-edit').extend(global)`.
|
||||||
|
|
||||||
|
|
||||||
|
Commands
|
||||||
|
========
|
||||||
|
|
||||||
|
edit
|
||||||
|
----
|
||||||
|
|
||||||
|
The first time you run `edit()` in a repl a temporary file is created, specific to that session,
|
||||||
|
and opened in your editor. Type away and then save and close the file when you're done. The file
|
||||||
|
will be loaded and executed at that time.
|
||||||
|
|
||||||
|
|
||||||
|
run
|
||||||
|
---
|
||||||
|
|
||||||
|
To run whatever command you've been working on without editing it again type `run()`.
|
||||||
|
|
||||||
|
|
||||||
|
setEditor
|
||||||
|
---------
|
||||||
|
|
||||||
|
`setEditor('mate -w')` will change your editor to TextMate for this session. Note that this
|
||||||
|
command changes the environment variable EDITOR for the repl process.
|
||||||
|
|
||||||
|
|
||||||
|
stash
|
||||||
|
-----
|
||||||
|
|
||||||
|
`stash('/path/to/a/file')` will save your command to the named file.
|
||||||
|
|
||||||
|
|
||||||
|
unstash
|
||||||
|
-------
|
||||||
|
|
||||||
|
`unstash('/path/to/a/file')` will restore the contents of that file for you to run and/or edit.
|
||||||
|
|
||||||
|
|
||||||
|
Future
|
||||||
|
======
|
||||||
|
|
||||||
|
Instead of polluting the global namespace with functions I'd rather extend Node's repl
|
||||||
|
to allow user-defined dot commands (just like `.break` and `.clear`), and then use that
|
||||||
|
capability to provide commands like `.edit` and `.stash <filename>`.
|
||||||
|
|
||||||
|
The first time edit() is run in a repl instead of an empty file the command should be seeded
|
||||||
|
with the last command that was executed.
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright 2010 Sami Samhuri sami@samhuri.net
|
||||||
|
|
||||||
|
MIT (see the file named [LICENSE](/samsonjs/repl-edit/blob/master/LICENSE))
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Copyright 2010 Sami Samhuri @_sjs
|
// Copyright 2010 Sami Samhuri @_sjs
|
||||||
// MIT license
|
// MIT license
|
||||||
//
|
//
|
||||||
// github.com/samsonjs/edit-repl
|
// github.com/samsonjs/repl-edit
|
||||||
//
|
//
|
||||||
|
|
||||||
// TODO proper error handling
|
// TODO proper error handling
|
||||||
|
|
@ -26,6 +26,7 @@ exports.extend = function(obj) {
|
||||||
|
|
||||||
obj.edit = function(editor) {
|
obj.edit = function(editor) {
|
||||||
editor = editor || process.ENV['EDITOR']
|
editor = editor || process.ENV['EDITOR']
|
||||||
|
// TODO seed the file with _repl.context._ if the file doesn't exist yet
|
||||||
pausingRepl(function(unpause) {
|
pausingRepl(function(unpause) {
|
||||||
var fds = [process.openStdin(), process.stdout, process.stdout]
|
var fds = [process.openStdin(), process.stdout, process.stdout]
|
||||||
, args = [_tmpfile]
|
, args = [_tmpfile]
|
||||||
|
|
|
||||||
14
package.json
14
package.json
|
|
@ -1,23 +1,23 @@
|
||||||
{ "name" : "edit-repl"
|
{ "name" : "repl-edit"
|
||||||
, "description" : "Edit code in the repl using a real text editor"
|
, "description" : "Edit code in the repl using a real text editor"
|
||||||
, "version" : "0.0.1"
|
, "version" : "0.0.1"
|
||||||
, "homepage" : "http://samhuri.net/node/edit-repl"
|
, "homepage" : "http://samhuri.net/node/repl-edit"
|
||||||
, "author" : "Sami Samhuri <sami@samhuri.net> (http://blog.izs.me)"
|
, "author" : "Sami Samhuri <sami@samhuri.net> (http://blog.izs.me)"
|
||||||
, "repository" :
|
, "repository" :
|
||||||
{ "type" : "git"
|
{ "type" : "git"
|
||||||
, "url" : "http://github.com/samsonjs/edit-repl.git"
|
, "url" : "http://github.com/samsonjs/repl-edit.git"
|
||||||
}
|
}
|
||||||
, "bugs" :
|
, "bugs" :
|
||||||
{ "mail" : "sami.samhuri+edit-repl@gmail.com"
|
{ "mail" : "sami.samhuri+repl-edit@gmail.com"
|
||||||
, "web" : "http://github.com/samsonjs/edit-repl/issues"
|
, "web" : "http://github.com/samsonjs/repl-edit/issues"
|
||||||
}
|
}
|
||||||
, "directories" : { "lib" : "./lib" }
|
, "directories" : { "lib" : "./lib" }
|
||||||
, "bin" : { "node-edit-repl" : "./repl.js" }
|
, "bin" : { "node-repl-edit" : "./repl.js" }
|
||||||
, "main" : "./lib/index"
|
, "main" : "./lib/index"
|
||||||
, "engines" : { "node" : ">=0.2.0" }
|
, "engines" : { "node" : ">=0.2.0" }
|
||||||
, "licenses" :
|
, "licenses" :
|
||||||
[ { "type" : "MIT"
|
[ { "type" : "MIT"
|
||||||
, "url" : "http://github.com/samsonjs/edit-repl/raw/master/LICENSE"
|
, "url" : "http://github.com/samsonjs/repl-edit/raw/master/LICENSE"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue