diff --git a/coffee/omelette.coffee b/coffee/omelette.coffee index 2be7396..6f4faf5 100644 --- a/coffee/omelette.coffee +++ b/coffee/omelette.coffee @@ -61,7 +61,16 @@ class Omelette extends EventEmitter compdef #{completion} #{program} elif type complete &>/dev/null; then #{completion}() { - COMPREPLY=( $(compgen -W '$(#{@program} --compbash --compgen "${COMP_CWORD}" "${COMP_WORDS[COMP_CWORD-1]}" "${COMP_LINE}")' -- "${COMP_WORDS[COMP_CWORD]}") ) + local cur prev + + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + + COMPREPLY=( $(compgen -W '$(#{@program} --compbash --compgen "${COMP_CWORD}" "${prev}" "${COMP_LINE}")' -- "$cur") ) + + [[ $COMPREPLY ]] && return + + _filedir } complete -F #{completion} #{program} fi diff --git a/src/omelette.js b/src/omelette.js index b080893..348c9ad 100644 --- a/src/omelette.js +++ b/src/omelette.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.9.1 /* * Omelette Simple Auto Completion for Node @@ -6,9 +6,9 @@ (function() { var EventEmitter, Omelette, fs, os, path, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __slice = [].slice; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty, + slice = [].slice; EventEmitter = require("events").EventEmitter; @@ -18,15 +18,15 @@ os = require("os"); - Omelette = (function(_super) { + Omelette = (function(superClass) { var log; - __extends(Omelette, _super); + extend(Omelette, superClass); log = console.log; function Omelette() { - var isZsh, _ref; + var isZsh, ref; this.compgen = process.argv.indexOf("--compgen"); this.install = process.argv.indexOf("--completion") > -1; isZsh = process.argv.indexOf("--compzsh") > -1; @@ -34,7 +34,7 @@ this.fragment = parseInt(process.argv[this.compgen + 1]) - (isZsh ? 1 : 0); this.word = process.argv[this.compgen + 2]; this.line = process.argv[this.compgen + 3]; - _ref = process.env, this.HOME = _ref.HOME, this.SHELL = _ref.SHELL; + ref = process.env, this.HOME = ref.HOME, this.SHELL = ref.SHELL; } Omelette.prototype.setProgram = function(programs) { @@ -46,9 +46,9 @@ }; Omelette.prototype.setFragments = function() { - var fragments; - fragments = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - this.fragments = fragments; + var fragments1; + fragments1 = 1 <= arguments.length ? slice.call(arguments, 0) : []; + this.fragments = fragments1; }; Omelette.prototype.generate = function() { @@ -72,7 +72,7 @@ return function(program) { var completion; completion = "_" + program + "_complette"; - return "### " + program + " completion - begin. generated by omelette.js ###\nif type compdef &>/dev/null; then\n " + completion + "() {\n compadd -- `" + _this.program + " --compzsh --compgen \"${CURRENT}\" \"${words[CURRENT-1]}\" \"${BUFFER}\"`\n }\n compdef " + completion + " " + program + "\nelif type complete &>/dev/null; then\n " + completion + "() {\n COMPREPLY=( $(compgen -W '$(" + _this.program + " --compbash --compgen \"${COMP_CWORD}\" \"${COMP_WORDS[COMP_CWORD-1]}\" \"${COMP_LINE}\")' -- \"${COMP_WORDS[COMP_CWORD]}\") )\n }\n complete -F " + completion + " " + program + "\nfi\n### " + program + " completion - end ###"; + return "### " + program + " completion - begin. generated by omelette.js ###\nif type compdef &>/dev/null; then\n " + completion + "() {\n compadd -- `" + _this.program + " --compzsh --compgen \"${CURRENT}\" \"${words[CURRENT-1]}\" \"${BUFFER}\"`\n }\n compdef " + completion + " " + program + "\nelif type complete &>/dev/null; then\n " + completion + "() {\n local cur prev\n \n cur=${COMP_WORDS[COMP_CWORD]}\n prev=${COMP_WORDS[COMP_CWORD-1]}\n \n COMPREPLY=( $(compgen -W '$(" + _this.program + " --compbash --compgen \"${COMP_CWORD}\" \"${prev}\" \"${COMP_LINE}\")' -- \"$cur\") )\n \n [[ $COMPREPLY ]] && return\n \n _filedir\n }\n complete -F " + completion + " " + program + "\nfi\n### " + program + " completion - end ###"; }; })(this)); if (this.isDebug) { @@ -163,8 +163,8 @@ })(EventEmitter); module.exports = function(template) { - var fragments, program, _omelette, _ref; - _ref = template.split(/\s+/), program = _ref[0], fragments = 2 <= _ref.length ? __slice.call(_ref, 1) : []; + var _omelette, fragments, program, ref; + ref = template.split(/\s+/), program = ref[0], fragments = 2 <= ref.length ? slice.call(ref, 1) : []; fragments = fragments.map(function(fragment) { return fragment.replace(/^\<+|\>+$/g, ''); });