-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CrateSidebar: Show "cargo install" snippet for crates with binaries
- Loading branch information
Showing
4 changed files
with
85 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,76 @@ | ||
<p local-class="copy-help">Run the following Cargo command in your project directory:</p> | ||
{{#if @binNames}} | ||
{{#if (is-clipboard-supported)}} | ||
<CopyButton | ||
@copyText={{this.cargoInstallCommand}} | ||
title="Copy command to clipboard" | ||
local-class="copy-button" | ||
> | ||
<span local-class="selectable">{{this.cargoInstallCommand}}</span> | ||
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} | ||
</CopyButton> | ||
{{else}} | ||
<code local-class="copy-fallback"> | ||
{{this.cargoInstallCommand}} | ||
</code> | ||
{{/if}} | ||
|
||
{{#if (is-clipboard-supported)}} | ||
<CopyButton | ||
@copyText={{this.cargoAddCommand}} | ||
title="Copy command to clipboard" | ||
local-class="copy-button" | ||
> | ||
<span local-class="selectable">{{this.cargoAddCommand}}</span> | ||
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} | ||
</CopyButton> | ||
{{else}} | ||
<code local-class="copy-fallback"> | ||
{{this.cargoAddCommand}} | ||
</code> | ||
<p local-class="copy-help"> | ||
Running the above command will globally install the following binaries: | ||
{{#if (eq @binNames.length 1)}} | ||
<span local-class="bin-name">{{get @binNames 0}}</span> | ||
{{else if (eq @binNames.length 2)}} | ||
<span local-class="bin-name">{{get @binNames 0}}</span> and <span local-class="bin-name">{{get @binNames 1}}</span> | ||
{{else}} | ||
{{#each @binNames as |binName index|~}} | ||
{{~#if (eq index 0)~}} | ||
<span local-class="bin-name">{{binName}}</span> | ||
{{~else if (eq index (sum @binNames.length -1))~}} | ||
, and <span local-class="bin-name">{{binName}}</span> | ||
{{~else~}} | ||
, <span local-class="bin-name">{{binName}}</span> | ||
{{~/if}} | ||
{{~/each}} | ||
{{/if}} | ||
</p> | ||
|
||
{{/if}} | ||
|
||
{{#if (and @hasLib @binNames)}} | ||
<h3>Install as library</h3> | ||
{{/if}} | ||
|
||
<p local-class="copy-help">Or add the following line to your Cargo.toml:</p> | ||
{{#if @hasLib}} | ||
<p local-class="copy-help">Run the following Cargo command in your project directory:</p> | ||
|
||
{{#if (is-clipboard-supported)}} | ||
<CopyButton | ||
@copyText={{this.cargoAddCommand}} | ||
title="Copy command to clipboard" | ||
local-class="copy-button" | ||
> | ||
<span local-class="selectable">{{this.cargoAddCommand}}</span> | ||
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} | ||
</CopyButton> | ||
{{else}} | ||
<code local-class="copy-fallback"> | ||
{{this.cargoAddCommand}} | ||
</code> | ||
{{/if}} | ||
|
||
<p local-class="copy-help">Or add the following line to your Cargo.toml:</p> | ||
|
||
{{#if (is-clipboard-supported)}} | ||
<CopyButton | ||
@copyText={{this.tomlSnippet}} | ||
title="Copy Cargo.toml snippet to clipboard" | ||
local-class="copy-button" | ||
> | ||
<span local-class="selectable">{{this.tomlSnippet}}</span> | ||
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} | ||
</CopyButton> | ||
{{else}} | ||
<code local-class="copy-fallback"> | ||
{{this.tomlSnippet}} | ||
</code> | ||
{{#if (is-clipboard-supported)}} | ||
<CopyButton | ||
@copyText={{this.tomlSnippet}} | ||
title="Copy Cargo.toml snippet to clipboard" | ||
local-class="copy-button" | ||
> | ||
<span local-class="selectable">{{this.tomlSnippet}}</span> | ||
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} | ||
</CopyButton> | ||
{{else}} | ||
<code local-class="copy-fallback"> | ||
{{this.tomlSnippet}} | ||
</code> | ||
{{/if}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters