Skip to content

Commit 7e4927b

Browse files
committed
Adding documentation for CLI
1 parent 59ddd30 commit 7e4927b

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

couscous.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ menu:
4343
order:
4444
text: Managing assets order
4545
relativeUrl: doc/order.html
46+
cli:
47+
text: Command line interface
48+
relativeUrl: doc/cli.html
4649
schema:
4750
text: discovery.json format
4851
relativeUrl: doc/discovery_schema.html

doc/cli.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Command line interface
3+
subTitle:
4+
currentMenu: cli
5+
---
6+
7+
Discovery comes with a CLI (command line interface).
8+
9+
You can use the CLI commands to:
10+
11+
- debug what is happening
12+
- modify your local `discovery.json`
13+
- hook third party tools (like Gulp or Webpack)
14+
15+
Actually, *discovery* is adding a set of commands to composer.
16+
17+
## Listing asset types
18+
19+
```bash
20+
$ composer discovery:list
21+
```
22+
23+
will output the list of asset types and the list of assets in each asset-type:
24+
25+
```
26+
my-asset-type-1:
27+
assetA
28+
assetB
29+
assetC
30+
my-asset-type-2:
31+
assetD
32+
```
33+
34+
You can also ask for the assets of a given asset-type:
35+
36+
```bash
37+
$ composer discovery:list my-asset-type-2
38+
```
39+
40+
will output:
41+
42+
```
43+
my-asset-type-2:
44+
assetD
45+
```
46+
47+
Finally, if you need more data, you can use the JSON output (maybe you want to output the metadata associated to each asset or you want to integrate the output with a third party tool).
48+
49+
```bash
50+
$ composer discovery:list --format=json
51+
```
52+
53+
## Dumping the Discovery files
54+
55+
Discovery is "dumping" a set of files that enable extremely quick access to the assets. **If you change manually a `discovery.json` file in your project, you will need to regenerate those files.** You can do this with the `discovery:dump` command:
56+
57+
```bash
58+
$ composer discovery:dump
59+
```
60+
61+
## Adding an asset
62+
63+
You can add an asset to an asset type using the `discovery:add` command:
64+
65+
```bash
66+
$ composer discovery:add "my-asset-type" "my-asset-value"
67+
```
68+
69+
The asset is added to the `discovery.json` file at the root of your project.
70+
71+
You can also set the priority while adding an asset:
72+
73+
```bash
74+
$ composer discovery:add "my-asset-type" "my-asset-value" --priority=42
75+
```
76+
77+
Note: currently, discovery does not support adding metadata via the command line. You will need to edit the `discovery.json` file manually to add metadata to an asset.
78+
79+
## Removing an asset
80+
81+
You can remove an asset from a project using the `discovery:remove` command:
82+
83+
```bash
84+
$ composer discovery:remove "my-asset-type" "my-asset-value"
85+
```
86+
87+
The asset is removed from the `discovery.json` file at the root of your project or a "remove" action is added in the `discovery.json` file at the root of your project (if the asset is defined in a dependency).

index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,18 @@ More documentation
115115
<a href="doc/order.html" class="btn btn-primary btn-large btn-block">Managing assets order</a>
116116
</div>
117117
<div class="col-xs-12 col-sm-6">
118-
<a href="doc/conventions.html" class="btn btn-primary btn-large btn-block">Naming conventions</a>
118+
<a href="doc/cli.html" class="btn btn-primary btn-large btn-block">Command line interface</a>
119119
</div>
120120
</div>
121121
<div class="row">
122+
<div class="col-xs-12 col-sm-6">
123+
<a href="doc/conventions.html" class="btn btn-primary btn-large btn-block">Naming conventions</a>
124+
</div>
122125
<div class="col-xs-12 col-sm-6">
123126
<a href="doc/internals.html" class="btn btn-primary btn-large btn-block">Internals and performance</a>
124127
</div>
128+
</div>
129+
<div class="row">
125130
<div class="col-xs-12 col-sm-6">
126131
<a href="doc/discovery_schema.html" class="btn btn-primary btn-large btn-block">discovery.json schema</a>
127132
</div>

0 commit comments

Comments
 (0)