Skip to content

Latest commit

 

History

History
37 lines (31 loc) · 1013 Bytes

File metadata and controls

37 lines (31 loc) · 1013 Bytes

autocomplete-lib

Simple library to make using the shell completion in ComputerCraft easier.

Example

This example will setup autocompletion following the table structure.

You would be able to use autocompletion for every parameter in one of the following commands:

  • <programname> get status short
  • <programname> get version latest
  • <programname> set name guest
  • <programname> delete cache
  • ...

The program name can be set manually by passing a string as second parameter. Autocomplete:registerAutocomplete(<table>, <string>|<nil>)

If the second parameter is nil, shell.getRunningProgram() will be used to determine the program name.

local scm = require('./scm')
local Autocomplete = scm:load('autocomplete')

Autocomplete:registerAutoComplete({
  get = {
    status = {"short", "detailed"},
    version = {"all", "latest"},
  },
  set = {
    name = {"admin", "guest"},
    config = {"default", "custom"},
  },
  delete = {
    temp = {"force", "safe"},
    "cache",
  },
})