From 6b5cb827239fc03735a173161eb0a4bc988fc6a5 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Fri, 24 Sep 2010 09:12:13 -0700 Subject: [PATCH] s/edit-repl/repl-edit/ and fleshed out readme a bit --- LICENSE | 2 +- Readme.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++- lib/index.js | 3 ++- package.json | 14 +++++----- 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/LICENSE b/LICENSE index 633af2e..c37eb40 100644 --- a/LICENSE +++ b/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 of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the diff --git a/Readme.md b/Readme.md index 30404ce..f3251ca 100644 --- a/Readme.md +++ b/Readme.md @@ -1 +1,72 @@ -TODO \ No newline at end of file +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 `. + +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)) \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 8ba73d1..58bfbbc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,7 +2,7 @@ // Copyright 2010 Sami Samhuri @_sjs // MIT license // -// github.com/samsonjs/edit-repl +// github.com/samsonjs/repl-edit // // TODO proper error handling @@ -26,6 +26,7 @@ exports.extend = function(obj) { obj.edit = function(editor) { editor = editor || process.ENV['EDITOR'] + // TODO seed the file with _repl.context._ if the file doesn't exist yet pausingRepl(function(unpause) { var fds = [process.openStdin(), process.stdout, process.stdout] , args = [_tmpfile] diff --git a/package.json b/package.json index c566d2d..b2156c8 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,23 @@ -{ "name" : "edit-repl" +{ "name" : "repl-edit" , "description" : "Edit code in the repl using a real text editor" , "version" : "0.0.1" -, "homepage" : "http://samhuri.net/node/edit-repl" +, "homepage" : "http://samhuri.net/node/repl-edit" , "author" : "Sami Samhuri (http://blog.izs.me)" , "repository" : { "type" : "git" - , "url" : "http://github.com/samsonjs/edit-repl.git" + , "url" : "http://github.com/samsonjs/repl-edit.git" } , "bugs" : - { "mail" : "sami.samhuri+edit-repl@gmail.com" - , "web" : "http://github.com/samsonjs/edit-repl/issues" + { "mail" : "sami.samhuri+repl-edit@gmail.com" + , "web" : "http://github.com/samsonjs/repl-edit/issues" } , "directories" : { "lib" : "./lib" } -, "bin" : { "node-edit-repl" : "./repl.js" } +, "bin" : { "node-repl-edit" : "./repl.js" } , "main" : "./lib/index" , "engines" : { "node" : ">=0.2.0" } , "licenses" : [ { "type" : "MIT" - , "url" : "http://github.com/samsonjs/edit-repl/raw/master/LICENSE" + , "url" : "http://github.com/samsonjs/repl-edit/raw/master/LICENSE" } ] } \ No newline at end of file