From 8e5a02fbe012c9fa5fa34961857f73936c6491a9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 20 Apr 2018 18:19:57 +0100 Subject: add descriptions and api docs --- README.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index b95514f..c4a50f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # pkg93 A package manager for Windows 93! +## Table of Contents +- [Installation](#installation) +- [Adding my package to the main repoistory](#adding-my-package-to-the-main-repoistory) +- [Making a Repository](#making-a-repository) +- [Making a Package](#making-a-package) +- [API](#api) + ## Installation Install the userscript in this repository named "inject.user.js". @@ -48,6 +55,7 @@ Firstly, you want to make a new folder called the name of the package. Then, you want to make a file called package.json in the folder. In it, there should be 4 keys. - `name`: **Must be the same as the folder name and command name!** (unless you've provided a uninstaller) +- `description` A description of your package. - `inject`: It should be the name of the injection script. - `uninstall`: Optional, It should be the name of the uninstaller script, if it doesn't exist pkg93 will simply delete the command for you. - `dependencies`: Optional, Packages this package depends on. These will be automatically installed. @@ -55,6 +63,7 @@ Here's a example: ```json { "name": "examplepkg", + "description": "my kewl pakeg!!11", "inject": "installer.js", "uninstall": "optionaluninstaller.js", "dependencies": [ @@ -70,3 +79,64 @@ examplepkg ├── installer.js └── optionaluninstaller.js ``` + +## API +### `pkg93.getConfig()` +Gets the configuration, or returns `false` if something went wrong. +Example: +```js +var config = pkg93.getConfig(); +if (config == false) { + alert("Something went wrong..."); +} else { + alert("You have " + config.pkglist.length + " packages available!"); +} +``` + +#### Configuration Format: +The configuration is a object with the following keys: +- `repos` All added repos. +- `installed` All installed packages. +- `pkglist` - All available packages. + +### `pkg93.pull()` +Refreshes the list of packages available. +Example: +```js +alert("You previously had " + config.pkglist.length + " packages available."); +pkg93.pull(); +alert("Now you have " + config.pkglist.length + " packages available!"); +``` + +### `pkg93.get(package)` +Tries to install `package`, then returns `true` if the package was installed or `false` if the package couldn't be installed. +```js +succeded = pkg93.get("wget93"); +if (succeded) { + alert("Installed wget93!"); +} else { + alert("Something went wrong..."); +} +``` + +### `pkg93.rm(package)` +Tries to remove `package`, then returns `true` if the package was removed or `false` if the package couldn't be removed. +```js +succeded = pkg93.rm("wget93"); +if (succeded) { + alert("Removed wget93!"); +} else { + alert("Something went wrong..."); +} +``` + +### `pkg93.pkginfo(package)` +Returns the package.json of `package` or `false` if it failed. +```js +package = pkg93.pkgInfo("wget93"); +if (package == false) { + alert("Something went wrong..."); +} else { + alert("wget93's description is: " + package.description); +} +``` -- cgit v1.2.3