Completion of help, commands and subjects
772523
private CompletionProvider helpCompletion() {
        return (code, cursor, anchor) -> {
            List<Suggestion> result;
            int pastSpace = code.indexOf(' ') + 1; // zero if no space
            if (pastSpace == 0) {
                // initially suggest commands (with slash) and subjects,
                // however, if their subject starts without slash, include
                // commands without slash
                boolean noslash = code.length() > 0 && !code.startsWith("/");
                result = new FixedCompletionProvider(commands.values().stream()
                        .filter(cmd -> cmd.kind.showInHelp || cmd.kind == CommandKind.HELP_SUBJECT)
                        .map(c -> ((noslash && c.command.startsWith("/"))
                                ? c.command.substring(1)
                                : c.command) + " ")
                        .toArray(String[]::new))
                        .completionSuggestions(code, cursor, anchor);
            } else if (code.startsWith("/se") || code.startsWith("se")) {
                result = new FixedCompletionProvider(SET_SUBCOMMANDS)
                        .completionSuggestions(code.substring(pastSpace), cursor - pastSpace, anchor);
            } else {
                result = Collections.emptyList();
            }
            anchor[0] += pastSpace;
            return result;
        };
    }
620042
def complete_hit(self, text, line, begidx, endidx):
        '''  '''
        return  [i for i in PsiturkNetworkShell.hit_commands if \
                 i.startswith(text)]
1087533
def show_help(fd=sys.stdout):
    '''
    
    '''
    with Modules() as m:
        fd.write(m.help())
691479
function completionHandler(currentInput, currentArgv) {
    commandExecuted = true
    const {scripts} = getPSConfig(currentArgv) || {}
    if (scripts) {
      return getCompletionScripts(scripts, currentInput)
    }
    return []
  }
1050092
def handle_completion(self):
        
        # We don't want these in the help, so handle them explicitely
        if len(sys.argv) > 1 and sys.argv[1].startswith("--help-completion-"):
            handler = getattr(self, sys.argv[1][2:].replace('-', '_'), None)
            if handler:
                print '\n'.join(sorted(handler()))
                self.STD_LOG_LEVEL = logging.DEBUG
                sys.exit(error.EX_OK)
1043020
def _do_help(self, cmd, args):
        
        print(self.doc_string())
        print()

        # Create data of the commands table.
        data_unsorted = []
        cls = self.__class__
        for name in dir(cls):
            obj = getattr(cls, name)
            if iscommand(obj):
                cmds = []
                for cmd in getcommands(obj):
                    cmds.append(cmd)
                cmd_str = ','.join(sorted(cmds))
                doc_str = textwrap.dedent(obj.__doc__).strip() if obj.__doc__ else \
                        '(no doc string available)'
                data_unsorted.append([cmd_str, doc_str])
        data_sorted = sorted(data_unsorted, key = lambda x: x[0])
        data = [['COMMANDS', 'DOC STRING']] + data_sorted

        # Create the commands table.
        table_banner = 'List of Available Commands'
        table = terminaltables.SingleTable(data, table_banner)
        table.inner_row_border = True
        table.inner_heading_row_border = True
        print(table.table)
250505
async def help(self):
        """"""
        if len(self.args.command) != 2:
            print('Which command do you want help with?', file=sys.stderr)
            return 1

        iface = [interface.RemoteControl,
                 interface.Metadata,
                 interface.Playing,
                 interface.AirPlay,
                 self.__class__,
                 DeviceCommands]
        for cmd in iface:
            for key, value in cmd.__dict__.items():
                if key.startswith('_') or key != self.args.command[1]:
                    continue

                if inspect.isfunction(value):
                    signature = inspect.signature(value)
                else:
                    signature = ' (property)'

                print('COMMAND:\n>> {0}{1}\n\nHELP:\n{2}'.format(
                    key, signature, inspect.getdoc(value)))
        return 0
1042852
def _get_completions(self):
        """"""
        completions = []
        self.begidx = self.l_buffer.point
        self.endidx = self.l_buffer.point
        buf=self.l_buffer.line_buffer
        if self.completer:
            # get the string to complete
            while self.begidx > 0:
                self.begidx -= 1
                if buf[self.begidx] in self.completer_delims:
                    self.begidx += 1
                    break
            text = ensure_str(u''.join(buf[self.begidx:self.endidx]))
            log(u'complete text="%s"' % ensure_unicode(text))
            i = 0
            while 1:
                try:
                    r = ensure_unicode(self.completer(text, i))
                except IndexError:
                    break
                i += 1
                if r is None:
                    break
                elif r and r not in completions:
                    completions.append(r)
                else:
                    pass
            log(u'text completions=<%s>' % map(ensure_unicode, completions))
        if (self.complete_filesystem == "on") and not completions:
            # get the filename to complete
            while self.begidx > 0:
                self.begidx -= 1
                if buf[self.begidx] in u' \t\n':
                    self.begidx += 1
                    break
            text = ensure_str(u''.join(buf[self.begidx:self.endidx]))
            log(u'file complete text="%s"' % ensure_unicode(text))
            completions = map(ensure_unicode, glob.glob(os.path.expanduser(text) + '*'))
            if self.mark_directories == u'on':
                mc = []
                for f in completions:
                    if os.path.isdir(f):
                        mc.append(f + os.sep)
                    else:
                        mc.append(f)
                completions = mc
            log(u'fnames=<%s>' % map(ensure_unicode, completions))
        return completions
814517
def cmd_help(param)
      send_response "214- The following commands are recognized."
      commands = COMMANDS
      str = ""
      commands.sort.each_slice(3) { |slice|
        str += "     " + slice.join("\t\t") + LBRK
      }
      send_response str, true
      send_response "214 End of list."
    end
864659
def help(self):
        """"""

        if self.params:
            command = self.params.pop().lstrip('-')

            if command in self.command.documentation:
                (aliases, doc) = self.command.documentation[command]
                (synopsis, body) = self._split_docstring(doc)

                print(synopsis)
                if body:
                    print()
                    print(body)

            else:
                raise CommandError('command {0} not known'.format(command))
        else:
            (synopsis, body) = self._split_docstring(__doc__)

            print(synopsis)
            print()
            print(body)
            print()
            print('Commands:')
            for command in sorted(self.command.documentation.keys()):
                print('   ', ', '.join(self.command.documentation[command][0]))
            print()
            print('Use "pymoctool --help COMMAND" for additional '
                  'information about a command.')
204905
def complete_config(self, text, line, begidx, endidx):
        '''  '''
        return  [i for i in PsiturkShell.config_commands if i.startswith(text)]
852828
def _complete_exit(self, cmd, args, text):
        """"""
        if args:
            return
        return [ x for x in { 'root', 'all', } \
                if x.startswith(text) ]
531701
def complete_get(self, text, line, begidx, endidx):
        """"""

        options = self.GET_OPTS

        if not text:
            completions = options
        else:
            completions = [f
                           for f in options
                           if f.startswith(text)
                           ]
        return completions
454772
def complete_worker(self, text, line, begidx, endidx):
        '''  '''
        return  [i for i in PsiturkNetworkShell.worker_commands if \
                 i.startswith(text)]
175713
protected void generalHelp(IsInfoSetFT info){
		//collect all commands belonging to a particular category
		String defKey = "__standard";
		Map<String, TreeMap<String, SkbShellCommand>> cat2Cmd = new TreeMap<>();
		for(CommandInterpreter ci : this.skbShell.getCommandMap().values()){
			for(SkbShellCommand ssc : ci.getCommands().values()){
				String cat = defKey;
				if(ssc.getCategory()!=null){
					cat = ssc.getCategory().getCategory();
				}
				if(!cat2Cmd.containsKey(cat)){
					cat2Cmd.put(cat, new TreeMap<>());
				}
				cat2Cmd.get(cat).put(ssc.getCommand(), ssc);
			}
		}

		//no argument, means general help
		info.addInfo("");
		info.addInfo("{} {}", this.skbShell.getDisplayName(), this.skbShell.getDescription());
		info.addInfo("");

		//do the commands per category, starting with "__standard"
		for(String cat : cat2Cmd.keySet()){
			String catDescr = cat;
			if(defKey.equals(cat)){
				catDescr = "standard commands";
			}
			info.addInfo("- {}: {}", new Object[]{catDescr, cat2Cmd.get(cat).keySet()});
		}
		info.addInfo("  try: 'help <command>' for more details");
	}
215890
function cmdHelp(command) {
        let ext = '';
        if (command.args && command.args.length > 0) {
            ext = command.args.join(' ');
        }
        if (ext && helpTopics[ext]) {
            const txt = `Help topic for \`${ext}\`\n\n${helpTopics[ext]}` +
                '\n\nIssue the `help` command without any parameters to see all available commands';
            command.reply(txt);

        } else {
            const help = `${getCommandHelps()}\n\n\\* Help topic available.\n\nIssue the \`help\` command with an ` +
                'available help topic as a parameter to read additonal help';
            command.reply(help);
        }
        return Promise.resolve();
    }
398783
def help_text(cls):
        """"""
        docs = [cmd_func.__doc__ for cmd_func in cls.commands.values()]

        # Don't want to include 'usage: ' or explanation.
        usage_lines = [doc.partition('\n')[0] for doc in docs]
        terse_lines = [line[len('Usage: '):] for line in usage_lines]
        terse_lines.sort()
        return '\n'.join(['Available commands:\n'] + terse_lines)