Skip to content

Commit 5eb44d3

Browse files
committed
Add docs for mbed add and mbed remove to create doc
1 parent ed5a629 commit 5eb44d3

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

docs/tools/CLI/cli-create.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,45 @@ $ mbed import https://github.com/ARMmbed/mbed-os-example-blinky#mbed-os-5.11.0
121121

122122
You can specify which version to import using `#` followed by a commit hash, a branch name, or a tag name. If you do not provide any of these (nor the `#` character), the latest commit on the `master` branch will be imported.
123123

124-
A project's default name is the last part of the URL (excluding `#` and its value). In the example above, the imported program's project folder is `mbed-os-example-blinky`. To specify a different name, supply it as an extra positional argument in the import command. For example, to name your project `my-blinky`, run:
124+
A project's default name is the last part of the URL (excluding `#` and its value). In the example above, the imported program's project folder is `mbed-os-example-blinky`. To specify a different name, supply it as an extra positional argument in the `mbed import` command. For example, to name your project `my-blinky`, run:
125125

126126
```
127127
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky#mbed-os-5.11.0 my-blinky
128128
```
129129

130130
<span class="tips">**Tip**: Running `mbed import` within an existing program will result in an error. To add a library to an existing project, use the `mbed add` command.</span>
131131

132+
### Adding libraries to programs
133+
134+
You can use the `mbed add` command to add a library to a program. Run the following command within your project directory:
135+
136+
```
137+
$ mbed add https://github.com/ARMmbed/mbed-cloud-client
138+
[mbed] Working path "C:\dev\mbed-os-example-blinky" (program)
139+
[mbed] Adding library "mbed-cloud-client" from "https://github.com/ARMmbed/mbed-cloud-client" at latest revision in the current branch
140+
[mbed] Updating reference "mbed-cloud-client" -> "https://github.com/ARMmbed/mbed-cloud-client/#377c6b8fb0f8b66be03408a438ff0cd96be0c454"
141+
```
142+
143+
Like the `mbed import` command, you can specify which version to use by using `#` at the end of the URL followed by a commit hash, a branch name, or a tag name. If you do not provide any of these (nor the `#` character), the latest commit on the `master` branch will be used.
144+
145+
The `mbed add` command will clone the repository specified, checkout to the correct version, and write the URL and _commit hash_ to a `.lib` file. Branches and tags can point to different commits over the lifetime of a repository, so to ensure the project's state is always reproducible, the commit hash is written to the `.lib` file. This `.lib` file should be committed to the project repository to track the dependency.
146+
147+
A library's default name is the last part of the URL (excluding `#` and its value). In the example above, the cloned library's folder is `mbed-cloud-client`. To specify a different name, supply it as an extra positional argument in the `mbed add` command. For example, to name your library `my-mcc`, run:
148+
149+
```
150+
$ mbed add https://github.com/ARMmbed/mbed-cloud-client my-mcc
151+
```
152+
153+
### Removing libraries
154+
155+
Remove a library (and it's `.lib` file) from your project by supplying the path to the library to the `mbed remove` command. Continuing the example from above, run the following from your project directory to remove the library that was added previously:
156+
157+
```
158+
$ mbed remove mbed-cloud-client
159+
```
160+
161+
Commit the removal of the `.lib` file from your project to remove the dependency.
162+
132163
### Updating programs and libraries
133164

134165
You can update programs and libraries on your local machine, so they update to the latest released version from the remote sources (Git or Mercurial).

0 commit comments

Comments
 (0)