@@ -8,38 +8,61 @@ import { Command } from "cliffy/command/mod.ts";
88import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts" ;
99import { createTempContext } from "../../core/temp.ts" ;
1010import { installExtension } from "../../extension/install.ts" ;
11+ import { installTool } from "../tools/tools.ts" ;
12+
13+ import { info } from "log/mod.ts" ;
1114
1215export const installCommand = new Command ( )
13- . hidden ( ) // TODO: unhide when ready
16+ . hidden ( )
1417 . name ( "install" )
1518 . arguments ( "[target:string]" )
19+ . arguments ( "<type:string> <target:string>" )
1620 . option (
1721 "--no-prompt" ,
18- "Do not prompt to confirm installation extension " ,
22+ "Do not prompt to confirm actions during installation " ,
1923 )
2024 . description (
21- "Installs a Quarto Extension into the current directory or Project directory ." ,
25+ "Installs an extension or global dependency ." ,
2226 )
2327 . example (
24- "Install extension from file " ,
25- "quarto install /Users/catmemes/tools/my-extension.tar.gz " ,
28+ "Install extension from Github " ,
29+ "quarto install extension <gh-organization>/<gh-repo> " ,
2630 )
2731 . example (
28- "Install extension from folder " ,
29- "quarto install /Users/catmemes/ tools/my-extension/ " ,
32+ "Install extension from file " ,
33+ "quarto install extension tools/my-extension.tar.gz " ,
3034 )
3135 . example (
3236 "Install extension from url" ,
33- "quarto install https://github.com/quarto-dev/quarto-extensions/releases/download/latest/my-extension.tar.gz" ,
37+ "quarto install extension <url>" ,
38+ )
39+ . example (
40+ "Install TinyTeX" ,
41+ "quarto install tool tinytex" ,
42+ )
43+ . example (
44+ "Install Chromium" ,
45+ "quarto install tool chromium" ,
3446 )
35- . action ( async ( options : { prompt ?: boolean } , target ?: string ) => {
36- await initYamlIntelligenceResourcesFromFilesystem ( ) ;
37- const temp = createTempContext ( ) ;
38- try {
39- if ( target ) {
40- await installExtension ( target , temp , options . prompt !== false ) ;
47+ . action (
48+ async ( options : { prompt ?: boolean } , type : string , target : string ) => {
49+ await initYamlIntelligenceResourcesFromFilesystem ( ) ;
50+ const temp = createTempContext ( ) ;
51+ try {
52+ if ( type . toLowerCase ( ) === "extension" ) {
53+ // Install an extension
54+ await installExtension ( target , temp , options . prompt !== false ) ;
55+ } else if ( type . toLowerCase ( ) === "tool" ) {
56+ // Install a tool
57+ await installTool ( target ) ;
58+ } else {
59+ // This is an unrecognized type option
60+ info (
61+ `Unrecorgnized option '${ type } ' - please choose 'tool' or 'extension'.` ,
62+ ) ;
63+ }
64+ } finally {
65+ temp . cleanup ( ) ;
4166 }
42- } finally {
43- temp . cleanup ( ) ;
44- }
45- } ) ;
67+ } ,
68+ ) ;
0 commit comments