diff --git a/app/components/crate-sidebar.hbs b/app/components/crate-sidebar.hbs index 3958be14a58..8e0aafb96b2 100644 --- a/app/components/crate-sidebar.hbs +++ b/app/components/crate-sidebar.hbs @@ -52,6 +52,8 @@ @crate={{@crate.name}} @version={{@version.num}} @exactVersion={{@requestedVersion}} + @hasLib={{not (@version.has_lib false)}} + @binNames={{@version.bin_names}} /> {{/unless}} diff --git a/app/components/crate-sidebar/install-instructions.hbs b/app/components/crate-sidebar/install-instructions.hbs index f5273b81b26..c7e813d29eb 100644 --- a/app/components/crate-sidebar/install-instructions.hbs +++ b/app/components/crate-sidebar/install-instructions.hbs @@ -1,33 +1,76 @@ -

Run the following Cargo command in your project directory:

+{{#if @binNames}} + {{#if (is-clipboard-supported)}} + + {{this.cargoInstallCommand}} + {{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} + + {{else}} + + {{this.cargoInstallCommand}} + + {{/if}} -{{#if (is-clipboard-supported)}} - - {{this.cargoAddCommand}} - {{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} - -{{else}} - - {{this.cargoAddCommand}} - +

+ Running the above command will globally install the following binaries: + {{#if (eq @binNames.length 1)}} + {{get @binNames 0}} + {{else if (eq @binNames.length 2)}} + {{get @binNames 0}} and {{get @binNames 1}} + {{else}} + {{#each @binNames as |binName index|~}} + {{~#if (eq index 0)~}} + {{binName}} + {{~else if (eq index (sum @binNames.length -1))~}} + , and {{binName}} + {{~else~}} + , {{binName}} + {{~/if}} + {{~/each}} + {{/if}} +

+ +{{/if}} + +{{#if (and @hasLib @binNames)}} +

Install as library

{{/if}} -

Or add the following line to your Cargo.toml:

+{{#if @hasLib}} +

Run the following Cargo command in your project directory:

+ + {{#if (is-clipboard-supported)}} + + {{this.cargoAddCommand}} + {{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} + + {{else}} + + {{this.cargoAddCommand}} + + {{/if}} + +

Or add the following line to your Cargo.toml:

-{{#if (is-clipboard-supported)}} - - {{this.tomlSnippet}} - {{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} - -{{else}} - - {{this.tomlSnippet}} - + {{#if (is-clipboard-supported)}} + + {{this.tomlSnippet}} + {{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}} + + {{else}} + + {{this.tomlSnippet}} + + {{/if}} {{/if}} \ No newline at end of file diff --git a/app/components/crate-sidebar/install-instructions.js b/app/components/crate-sidebar/install-instructions.js index 09694d2a1d6..e6a8ec185f4 100644 --- a/app/components/crate-sidebar/install-instructions.js +++ b/app/components/crate-sidebar/install-instructions.js @@ -1,6 +1,12 @@ import Component from '@glimmer/component'; export default class InstallInstructions extends Component { + get cargoInstallCommand() { + return this.args.exactVersion + ? `cargo install ${this.args.crate}@${this.args.version}` + : `cargo install ${this.args.crate}`; + } + get cargoAddCommand() { return this.args.exactVersion ? `cargo add ${this.args.crate}@=${this.args.version}` diff --git a/app/components/crate-sidebar/install-instructions.module.css b/app/components/crate-sidebar/install-instructions.module.css index 9f20ec49c5e..0499522eb20 100644 --- a/app/components/crate-sidebar/install-instructions.module.css +++ b/app/components/crate-sidebar/install-instructions.module.css @@ -1,5 +1,6 @@ .copy-help { font-size: 12px; + overflow-wrap: break-word; } .copy-button, @@ -51,3 +52,8 @@ .selectable { user-select: text; } + +.bin-name { + font-family: var(--font-monospace); + font-weight: bold; +}