Skip to content

Commit

Permalink
Improve the UX of README command codeblocks
Browse files Browse the repository at this point in the history
* Removes the leading terminal prompt `$` from single command
  codeblocks, so that GitHub's "copy to clipboard" feature can be
  used to copy the commands directly into the terminal.
* Switches multi-line "command plus example output" codeblocks
  from language `shell` to `console` to prevent broken syntax
  highlighting (e.g. the "test" in "To test your buildpack" was being
  highlighted as a bash script, not console output).
  • Loading branch information
edmorley committed Oct 18, 2023
1 parent 86cf63c commit 4cf943c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ be carried out once and don't need to be repeated for each buildpack you will wr
Start by installing [libcnb-cargo](https://crates.io/crates/libcnb-cargo), which provides the `libcnb` Cargo command
that we will use later to package our buildpack:

```shell
$ cargo install libcnb-cargo
```
cargo install libcnb-cargo
```

#### Cross-compilation prerequisites
Expand All @@ -41,8 +41,8 @@ eventually run. This means we have to cross-compile our buildpack. The `libcnb p
up your environment depending on your host platform, but we always need the appropriate target platform for Rust, which
we can install with `rustup`:

```shell
$ rustup target add x86_64-unknown-linux-musl
```
rustup target add x86_64-unknown-linux-musl
```

#### Docker
Expand All @@ -61,15 +61,14 @@ Find their documentation about installing it here: <https://buildpacks.io/docs/i
After we've successfully set up our development environment, we can move on and create a new Rust project for our
buildpack. First, we create a new binary crate with Cargo:

```shell
$ cargo new my-buildpack
Created binary (application) `my-buildpack` package
```
cargo new my-buildpack
```

Then, add the `libcnb` dependency to your project's `Cargo.toml`:

```shell
$ cargo add libcnb
```
cargo add libcnb
```

Note: If you get an error about `cargo add` not being a supported command, make sure you are
Expand Down Expand Up @@ -177,7 +176,7 @@ your development environment, you have access to the `libcnb` Cargo command that

In your project directory, run `cargo libcnb package` to start packaging:

```shell
```console
$ cargo libcnb package
🚚 Preparing package directory...
🖥️ Gathering Cargo configuration (for x86_64-unknown-linux-musl)
Expand Down Expand Up @@ -208,7 +207,7 @@ You might have seen in the output that we're now ready to run our buildpack loca
with `pack`. Before we can do this, we need an application to build. Since our buildpack does not interact with the
application code at all, we just create an empty directory and use that as our application:

```shell
```console
$ mkdir bogus-app
$ pack build my-image --buildpack packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_my-buildpack --path bogus-app --builder heroku/builder:22
...
Expand Down Expand Up @@ -241,7 +240,7 @@ Successfully built image my-image
The newly created Docker image can be run in the same way as you would a Docker image created via `docker build`.
If all went well, you should see our "Hello World!" message in your terminal:

```shell
```console
$ docker run my-image
Hello World!
```
Expand Down
8 changes: 4 additions & 4 deletions libcnb-cargo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ A Cargo command for managing buildpacks written with [libcnb.rs](https://github.

## Installation

```shell
$ cargo install libcnb-cargo
```
cargo install libcnb-cargo
```

## Usage

Currently, there is only one sub-command: `package`. It allows users to package their
Rust buildpack in a spec-compliant manner and helps with cross-compilation.

```shell
```console
$ cargo libcnb package --help
Packages a libcnb.rs Cargo project as a Cloud Native Buildpack

Expand All @@ -30,7 +30,7 @@ Options:
Using it is fairly simple, run `cargo libcnb package` inside the buildpack's
project directory:

```shell
```console
$ cargo libcnb package
🚚 Preparing package directory...
🖥️ Gathering Cargo configuration (for x86_64-unknown-linux-musl)
Expand Down

0 comments on commit 4cf943c

Please sign in to comment.