Skip to content

Conversation

@ColdIV
Copy link
Member

@ColdIV ColdIV commented Sep 7, 2022

add autocomplete

  • completes all available commands
  • completes fixed parameters (e.g. scm remove all)
  • completes installed programs and libraries (e.g. scm update ... or scm remove ...)
  • completes programs and libraries from github (e.g. scm add ... or scm require ...)
    (this uses the github api, it will only download from github if a) it never has before or b) it has been refreshed manually)
  • implements the new refresh command scm refresh to update program and library names from github and refresh autocomplete in general
  • completes all available config names
  • completes all available commands for the help command
  • add small interface when scm is run directly without args
  • updates readme (add refresh command)

resolves #4

add small interface when scm is run directly without args
@ColdIV ColdIV added the enhancement New feature or request label Sep 7, 2022
@ColdIV ColdIV requested a review from ChristophLHR September 7, 2022 23:16
@ColdIV ColdIV self-assigned this Sep 7, 2022
add function to be used in startup.lua (scm:cli(true))
scm.lua Outdated

local responseTable = textutils.unserializeJSON(response)
for i = 1, #responseTable, 1 do
if string.sub(responseTable[i]["name"], -string.len(self.config["programSuffix"])) == self.config["programSuffix"] then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a mouthfull to read through

Comment on lines 180 to 186
for i = 1, #responseTable, 1 do
if string.sub(responseTable[i]["name"], -string.len(self.config["programSuffix"])) == self.config["programSuffix"] then
programs[string.sub(responseTable[i]["name"], 0, string.len(responseTable[i]["name"])-string.len(self.config["programSuffix"]))] = {}
elseif string.sub(responseTable[i]["name"], -string.len(self.config["librarySuffix"])) == self.config["librarySuffix"] then
libraries[string.sub(responseTable[i]["name"], 0, string.len(responseTable[i]["name"])-string.len(self.config["librarySuffix"]))] = {}
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for i = 1, #responseTable, 1 do
if string.sub(responseTable[i]["name"], -string.len(self.config["programSuffix"])) == self.config["programSuffix"] then
programs[string.sub(responseTable[i]["name"], 0, string.len(responseTable[i]["name"])-string.len(self.config["programSuffix"]))] = {}
elseif string.sub(responseTable[i]["name"], -string.len(self.config["librarySuffix"])) == self.config["librarySuffix"] then
libraries[string.sub(responseTable[i]["name"], 0, string.len(responseTable[i]["name"])-string.len(self.config["librarySuffix"]))] = {}
end
end
local progSuffix = self.config["programSuffix"]
local libSuffix = self.config["librarySuffix"]
local name
for i = 1, #responseTable, 1 do
name = responseTable[i]["name"]
if string.sub(name, -string.len(progSuffix)) == progSuffix then
programs[string.sub(name, 0, string.len(name)-string.len(progSuffix))] = {}
elseif string.sub(name, -string.len(libSuffix)) == libSuffix then
libraries[string.sub(responsname, 0, string.len(name)-string.len(libSuffix))] = {}
end
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in newest commit

@ColdIV ColdIV merged commit ac9499a into master Sep 8, 2022
@ColdIV ColdIV deleted the issue-4/autocomplete branch September 8, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

add autocomplete

3 participants