Skip to content

Commit b52e323

Browse files
committed
remove rootDirectory from config
split apiGithubGetRepos in two configurations update README.md
1 parent b105dd0 commit b52e323

File tree

2 files changed

+41
-57
lines changed

2 files changed

+41
-57
lines changed

README.md

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,57 @@
1-
# script-manager
1+
# Script Manager
22

3-
A dependency manager for scripts to use in the mod CC: Tweaked of Minecraft.
3+
**SCM** is a script manager for Minecrafts ComputerCraft mod.
44

5-
# Install
6-
Download SCM with the following command:
5+
We are using [CC: Tweaked](https://tweaked.cc/) and in some cases some additional peripherals, which we ideally mention in the repositories of the scripts that use them.
6+
7+
**SCM** is used so you don't have to worry too much about your libraries. You can focus on writing your program and if it uses external libraries, they will be installed automatically. Furthermore, if you want to keep your scripts up-to-date, **SCM** saves the source of the programs you've installed and lets you update them by just typing `scm update <name>`.
8+
9+
[Documentation](https://github.com/mc-cc-scripts/script-manager/wiki) | [MIT License](https://github.com/mc-cc-scripts/script-manager/blob/master/LICENSE)
10+
11+
# Quickstart
12+
## Installation
13+
Download **SCM** with the following command:
714

815
pastebin run 1kKZ8zTS
916

10-
# Commands
11-
**Note:** "From GitHub" usually refers to repositories within this project. "Script" refers to programs **and** libraries.
12-
## add
13-
- `<name>`: Downloads a program from GitHub. Programs always have the suffix `-prog` ([Naming Conventions](https://github.com/mc-cc-scripts/.github/blob/master/profile/README.md#naming-conventions)). The suffix should not be added to the name.
14-
- `<name>@<pastebin code>`: Downloads a program from Pastebin.
15-
## require
16-
- `<name>`: Downloads a library from GitHub. Libraries always have the suffix `-lib` ([Naming Conventions](https://github.com/mc-cc-scripts/.github/blob/master/profile/README.md#naming-conventions)). The suffix should not be added to the name.
17-
- `<name>@<pastebin code>`: Downloads a library from Pastebin.
18-
## update
19-
By default, without parameters, `update` updates the SCM script.
20-
- `<name>`: Removes and downloads an installed script by name.
21-
- `all`: Removes and downloads all installed scripts.
22-
- `<name> <sourceName>`: Removes and downloads an installed script from a specific source. Sources can be added via the `source` command.
23-
## source
24-
**`source` commands have not yet been implemented.**
25-
Feel free to do so [here](https://github.com/mc-cc-scripts/script-manager/issues/2).
26-
- `add <scriptName> <sourceName> <source>`: Adds a source (URL, Pastebin Code, ...) with a name to a script.
27-
- `get <scriptName>`: Shows all sources of a script.
28-
- `remove <scriptName> <sourceName>`: Removes a source from a script.
29-
- `default <scriptName> <sourceName>`: Sets a specific source to the default of a script. The previous default script gets a generated name.
30-
- `rename <scriptName> <sourceName> <newSourceName>`: Updates the name of a source.
31-
## remove
32-
- `<name>`: Deletes a script by name.
33-
- `all`: Deletes all scripts.
34-
## list
35-
Shows all installed scripts.
36-
## config
37-
Shows all available configurations.
38-
- `<name>`: Shows the value of a specific configuration.
39-
- `<name> <value>`: Updates the value of a specific configuration.
40-
## refresh
41-
Downloads the names of all programs and libraries of the official repository.
42-
Refreshes autocomplete.
43-
## help
44-
Shows all available commands and their description.
45-
- `<name>`: Shows the description of a command by name.
17+
## Configuration
18+
There are various configurations you can change. If you want to use your own repository, you can easily change it in the [configuration](https://github.com/mc-cc-scripts/script-manager/wiki/Configuration).
19+
20+
## Commands
21+
You can find a complete list of all commands [here](https://github.com/mc-cc-scripts/script-manager/wiki/Commands).
4622

47-
# Example
48-
## Requires
49-
If you want to load a library within a program and keep it updated through SCM, then you can do that with the following notation:
23+
## Download a program
24+
You can either download a program from GitHub with
25+
```
26+
scm add testProgram
27+
```
28+
or from Pastebin with
29+
```
30+
scm add testProgram@7ByR3NYn
31+
```
5032

33+
## Build scripts
34+
### Program
35+
To add libraries to your programs, you will have to require **SCM** first.
5136
```lua
5237
local scm = require("./scm")
38+
```
39+
Then you can load your libraries as follows:
40+
```lua
5341
scm:load("testLibrary")
5442
```
43+
If a library is missing, **SCM** will try to install it.
5544

56-
If the library is already called by a program using this SCM loader, SCM will check all libraries loaded for these comments:
57-
58-
45+
### Libraries
46+
Furthermore, **SCM** can also check nested sub-libraries within the loaded library. To do that, you will have to add a comment before requiring the library. This has the advantage of the libraries still being usable without **SCM**, as a comment does not interfer with the logic of the script.
5947
```lua
6048
--@requires subLibrary
6149
require("./libs/subLibrary")
62-
6350
```
64-
The comment tells SCM to look for the sub-library and, if it's not already installed, it will try to download it.
65-
This prevents the program from crashing, should SCM not be installed.
66-
6751
### Pastebin
68-
69-
If there is a "@" after the library name, it will look for the library and install it from the Pastebin-Code instead of GitHub
52+
You can also use libraries hosted on Pastebin. Just attach the Pastebin code at the end of the name, separated by an `@`.
7053
```lua
7154
--@requires subLibrary@z4VRj21Y
55+
require("./libs/subLibrary")
7256
```
7357

scm.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ scm.config = {
1212
["programSuffix"] = "-prog",
1313
["librarySuffix"] = "-lib",
1414
["infoFile"] = "files.txt", -- provides the structure of a git repo (paths to all files)
15-
["apiGithubGetRepos"] = "https://api.github.com/orgs/mc-cc-scripts/repos?type=all&per_page=100&page=1",
16-
-- Local Settings
15+
["apiGithubURL"] = "https://api.github.com/orgs/",
16+
["apiGithubGetRepos"] = "/repos?type=all&per_page=100&page=1",
1717
["installScript"] = "1kKZ8zTS",
18-
["rootDirectory"] = "",
18+
-- Local Settings
1919
["programDirectory"] = "progs/",
2020
["libraryDirectory"] = "libs/",
2121
["configDirectory"] = "config/",
@@ -173,7 +173,7 @@ function scm:refreshRepoScripts ()
173173
local programs = {}
174174
local libraries = {}
175175

176-
local request = http.get(self.config["apiGithubGetRepos"])
176+
local request = http.get(self.config["apiGithubURL"] .. self.config["user"] .. self.config["apiGithubGetRepos"])
177177
if request then
178178
local response = request.readAll()
179179
request.close()
@@ -503,7 +503,7 @@ function scm:downloadURL (sourceObject, targetDirectory, updateObj)
503503
request.close()
504504

505505
if content then
506-
local file = fs.open(self.config["rootDirectory"] .. targetDirectory .. sourceObject.name, "w")
506+
local file = fs.open(targetDirectory .. sourceObject.name, "w")
507507
file.write(content)
508508
file.close()
509509
return sourceObject, true

0 commit comments

Comments
 (0)