Skip to content

Commit e9e587f

Browse files
committed
Add cargo add instruction to crate-sidebar
1 parent 90db973 commit e9e587f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

app/components/crate-sidebar.hbs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,23 @@
3737
<div>
3838
<h2 local-class="heading">Install</h2>
3939

40-
<p local-class="copy-help">Add the following line to your Cargo.toml file:</p>
40+
<p local-class="copy-help">Run the following Cargo command in your project directory:</p>
41+
{{#if (is-clipboard-supported)}}
42+
<CopyButton
43+
@copyText={{this.cargoAddCommand}}
44+
title="Copy command to clipboard"
45+
local-class="copy-button"
46+
>
47+
<span>{{this.cargoAddCommand}}</span>
48+
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}}
49+
</CopyButton>
50+
{{else}}
51+
<code local-class="copy-fallback">
52+
{{this.cargoAddCommand}}
53+
</code>
54+
{{/if}}
55+
56+
<p local-class="copy-help">Or add the following line to your Cargo.toml:</p>
4157
{{#if (is-clipboard-supported)}}
4258
<CopyButton
4359
@copyText={{this.tomlSnippet}}

app/components/crate-sidebar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export default class CrateSidebar extends Component {
1414
return homepage && (!repository || simplifyUrl(repository) !== simplifyUrl(homepage));
1515
}
1616

17+
get cargoAddCommand() {
18+
return `cargo add ${this.args.crate.name}`;
19+
}
20+
1721
get tomlSnippet() {
1822
return `${this.args.crate.name} = "${this.args.version.num}"`;
1923
}

0 commit comments

Comments
 (0)