Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ add a fairly verbose --help ]
  • Loading branch information
Jacob Rothstein committed Oct 29, 2010
1 parent 3ab497c commit 9596d8f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/cli.js
Expand Up @@ -20,7 +20,19 @@ cli.repl = (function(args) {
return require("sibilant/repl");
});

cli.help = (function(args) {
// args:rest
var args = Array.prototype.slice.call(arguments, 0);

return console.log("Hi there! Thanks for installing sibilant.\nPlease leave feedback on github issues (http://github.com/jbr/sibilant/issues)\n\nThe current commandline options are:\n--------------------------------------------------------------------------------\n\n-h / --help This message\n\n--repl / [no args] Sibilant interactive command prompt\n\n--execute / -x This is a flag. Execute input files in order supplied.\n\n--output DIR / -o DIR Output input files to this dir, replacing .lisp with .js.\n\n--input FILE / -i FILE / FILE\n Add this file to the input files. If the execute flag is\n set, input files will be executed. If an output dir is\n specified, each file will be written to that dir.\n Otherwise, each file will be written to STDOUT.\n\n--------------------------------------------------------------------------------\n\nExamples\n\nto compile sibilant\n$ git clone git://github.com/jbr/sibilant.git\n$ npm link .\n$ sibilant src/*.lisp -o lib\n$ sibilant -x test/test.lisp # you're now running a sibilant you just compiled.\n\nto compile one file to stdout\n$ sibilant test/test.lisp\n\nto compile a file to a directory\n$ sibilant test/test.lisp -o . # put test.js here\nor\n$ sibilant --input test/test.lisp --output .\n\nto run a file\n$ sibilant -x test/test.lisp\n\nto enter the repl\n$ sibilant\nor\n$ sibilant --repl\n\n");
});

var cliOptions = options(cli);
(function() {
if (((Object.keys(cliOptions)).length === 0)) {
return cli.repl();
};
})()
var outputDir = (function() {
if (cliOptions.output) {
return (cliOptions.output)[0];
Expand Down
54 changes: 54 additions & 0 deletions src/cli.lisp
Expand Up @@ -17,8 +17,61 @@
(defun cli.repl (&rest args)
(require "sibilant/repl"))

(defun cli.help (&rest args)
(console.log
"Hi there! Thanks for installing sibilant.
Please leave feedback on github issues (http://github.com/jbr/sibilant/issues)
The current commandline options are:
--------------------------------------------------------------------------------
-h / --help This message
--repl / [no args] Sibilant interactive command prompt
--execute / -x This is a flag. Execute input files in order supplied.
--output DIR / -o DIR Output input files to this dir, replacing .lisp with .js.
--input FILE / -i FILE / FILE
Add this file to the input files. If the execute flag is
set, input files will be executed. If an output dir is
specified, each file will be written to that dir.
Otherwise, each file will be written to STDOUT.
--------------------------------------------------------------------------------
Examples
to compile sibilant
$ git clone git://github.com/jbr/sibilant.git
$ npm link .
$ sibilant src/*.lisp -o lib
$ sibilant -x test/test.lisp # you're now running a sibilant you just compiled.
to compile one file to stdout
$ sibilant test/test.lisp
to compile a file to a directory
$ sibilant test/test.lisp -o . # put test.js here
or
$ sibilant --input test/test.lisp --output .
to run a file
$ sibilant -x test/test.lisp
to enter the repl
$ sibilant
or
$ sibilant --repl
"))

(defvar cli-options (options cli))

(when (empty? (keys cli-options))
(cli.repl))

(defvar output-dir
(when cli-options.output (first cli-options.output)))

Expand All @@ -39,6 +92,7 @@
(set module 'filename input-path)
(script.run-in-context js context 'sibilant))


(each (input-file) (or cli-options.input (list))
(defvar input-path (path.join (process.cwd) input-file)
translated (sibilant.translate-file input-path))
Expand Down

0 comments on commit 9596d8f

Please sign in to comment.