Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
docs(gitpage): finish context api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
erha19 committed Mar 29, 2019
1 parent d239fdf commit 2b90d9b
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 13 deletions.
23 changes: 11 additions & 12 deletions docs/_sidebar.md
Expand Up @@ -2,18 +2,17 @@
* [Getting Started](/getting-started)
* [Plugin Development Guide](/plugin-development-guide)
* [Context API](/context-api)
* [config](/toolbox-config)
* [open](/toolbox-open)
* [filesystem](/toolbox-fs)
* [semver](/toolbox-semver)
* [inquirer](/toolbox-inquirer)
* [http](/toolbox-http)
* [parameters](/toolbox-parameters)
* [print](/toolbox-logger)
* [strings](/toolbox-strings)
* [system](/toolbox-system)
* [template](/toolbox-template)
* [patching](/toolbox-patching)
* [parameters](/context-parameters)
* [config](/context-config)
* [open](/context-open)
* [filesystem](/context-fs)
* [semver](/context-semver)
* [inquirer](/context-inquirer)
* [http](/context-http)
* [print](/context-logger)
* [strings](/context-strings)
* [system](/context-system)
* [patching](/context-patching)
* Tutorials
* [Tutorial: Making a Extension](/tutorial-making-a-extension)
* [Tutorial: Making a Plugin](/tutorial-making-a-plugin)
Expand Down
52 changes: 51 additions & 1 deletion docs/context-api.md
@@ -1,3 +1,53 @@
# Context API

TODO
Let's explore the inside of the Weex Toolkit "Context API".

```js
module.exports = {
name: 'dostuff',
alias: 'd',
run: async (context) => {
// great! now what?
},
}
```

Here's what's available inside the `context` object you see all over Gluegun.

| name | provides the... | 3rd party |
| -------------- | -------------------------------------------------- | ------------------------------ |
| **meta** | information about the currently running CLI | |
| **config** | configuration options from the app or plugin | |
| **fs** | ability to copy, move & delete files & directories | fs-jetpack |
| **http** | ability to talk to the web | apisauce |
| **parameters** | command line arguments and options | yargs-parser |
| **patching** | manipulating file contents easily | fs-jetpack |
| **print** | tools to print output to the command line | colors, ora |
| **inquirer** | tools to acquire extra command line user input | inquirer |
| **semver** | utilities for working with semantic versioning | semver |
| **strings** | some string helpers like case conversion, etc. | lodash & ramda |
| **system** | ability to execute | node-which, execa, cross-spawn |
| **open** | ability to open files | open, chrome-opn |

The `context` has "drawers" full of useful tools for building CLIs. For example, the `context.meta.version` function can be invoked like this:

```js
module.exports = {
name: 'dostuff',
alias: 'd',
run: async (context) => {
// use them like this...
context.logger.info(context.meta.version())

// or destructure!
const {
logger: { info },
meta: { version },
} = toolbox
info(version())
},
}
```

To learn more about each tool, explore the rest of the `context-*.md` files in this folder.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions docs/toolbox-open.md → docs/context-open.md
Expand Up @@ -19,3 +19,12 @@ open('https://weex.io', 'chrome', (error) => {
}
})
```

## chromeOpn

Powered by [chrome-opn](https://www.npmjs.com/package/chrome-opn).

```js
const chromeOpn = context.chromeOpn
chromeOpn('https://weex.io', null, false)
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2b90d9b

Please sign in to comment.