55*
66*/
77import { Command } from "cliffy/command/mod.ts" ;
8- import { Select } from "cliffy/prompt/select.ts" ;
98import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts" ;
109import { createTempContext } from "../../core/temp.ts" ;
1110import { installExtension } from "../../extension/install.ts" ;
12- import {
13- allTools ,
14- installableTool ,
15- installableTools ,
16- installTool ,
17- toolSummary ,
18- } from "../tools/tools.ts" ;
11+ import { installTool } from "../tools/tools.ts" ;
1912
2013import { info } from "log/mod.ts" ;
21- import { withSpinner } from "../../core/console.ts" ;
22- import { InstallableTool } from "../tools/types.ts" ;
14+ import { loadTools , selectTool } from "../remove/tools-console.ts" ;
2315
2416export const installCommand = new Command ( )
2517 . hidden ( )
2618 . name ( "install" )
27- . arguments ( "[target:string]" )
2819 . arguments ( "<type:string> [target:string]" )
2920 . option (
3021 "--no-prompt" ,
31- "Do not prompt to confirm actions during installation " ,
22+ "Do not prompt to confirm actions" ,
3223 )
3324 . description (
3425 "Installs an extension or global dependency." ,
3526 )
3627 . example (
37- "Install extension from Github" ,
38- "quarto install extension <gh-organization >/<gh-repo>" ,
28+ "Install extension ( Github) " ,
29+ "quarto install extension <gh-org >/<gh-repo>" ,
3930 )
4031 . example (
41- "Install extension from file" ,
42- "quarto install extension tools/my-extension.tar.gz " ,
32+ "Install extension ( file) " ,
33+ "quarto install extension <path-to-zip> " ,
4334 )
4435 . example (
45- "Install extension from url" ,
36+ "Install extension ( url) " ,
4637 "quarto install extension <url>" ,
4738 )
4839 . example (
@@ -53,6 +44,10 @@ export const installCommand = new Command()
5344 "Install Chromium" ,
5445 "quarto install tool chromium" ,
5546 )
47+ . example (
48+ "Choose tool to install" ,
49+ "quarto install tool" ,
50+ )
5651 . action (
5752 async ( options : { prompt ?: boolean } , type : string , target ?: string ) => {
5853 await initYamlIntelligenceResourcesFromFilesystem ( ) ;
@@ -71,37 +66,15 @@ export const installCommand = new Command()
7166 // Use the tool name
7267 await installTool ( target ) ;
7368 } else {
74- // Present a list of tools
75- const toolsToInstall = await notInstalledTools ( ) ;
76- if ( toolsToInstall . length === 0 ) {
77- info ( "All tools already installed." ) ;
78- const summaries = [ ] ;
79- for ( const tool of installableTools ( ) ) {
80- const summary = await toolSummary ( tool ) ;
81- summaries . push ( summary ) ;
82- }
69+ // Not provided, give the user a list to choose from
70+ const allTools = await loadTools ( ) ;
71+ if ( allTools . filter ( ( tool ) => ! tool . installed ) . length === 0 ) {
72+ info ( "All tools are already installed." ) ;
8373 } else {
84- const toolsWithSummary = [ ] ;
85- for ( const tool of toolsToInstall ) {
86- const summary = await toolSummary ( tool . name ) ;
87- toolsWithSummary . push ( { tool, summary } ) ;
88- }
89-
90- const toolTarget : string = await Select . prompt ( {
91- message : "Select a tool to install" ,
92- options : toolsWithSummary . map ( ( toolWithSummary ) => {
93- return {
94- name : `${ toolWithSummary . tool . name } ${
95- toolWithSummary . summary ?. latestRelease . version
96- ? " (" +
97- toolWithSummary . summary ?. latestRelease . version + ")"
98- : ""
99- } `,
100- value : toolWithSummary . tool . name ,
101- } ;
102- } ) ,
103- } ) ;
74+ // Select which tool should be installed
75+ const toolTarget = await selectTool ( allTools , "install" ) ;
10476 if ( toolTarget ) {
77+ info ( "" ) ;
10578 await installTool ( toolTarget ) ;
10679 }
10780 }
@@ -117,12 +90,3 @@ export const installCommand = new Command()
11790 }
11891 } ,
11992 ) ;
120-
121- async function notInstalledTools ( ) {
122- const toolsToInstall : InstallableTool [ ] = [ ] ;
123- await withSpinner ( { message : "Inspecting tools" } , async ( ) => {
124- const all = await allTools ( ) ;
125- toolsToInstall . push ( ...all . notInstalled ) ;
126- } ) ;
127- return toolsToInstall ;
128- }
0 commit comments