@@ -11,6 +11,7 @@ import { expandFileLists } from '../util/fileLists.js';
1111import { isProject } from '../util/projectLoader.js' ;
1212import { buildTestData } from './buildTestData/index.js' ;
1313import { buildWindowsPackageInstaller } from './buildWindowsPackageInstaller/index.js' ;
14+ //import { buildWindowsPackageInstaller } from './buildWindowsPackageInstaller/index.js';
1415
1516
1617function commandOptionsToCompilerOptions ( options : any ) : CompilerOptions {
@@ -32,31 +33,38 @@ function commandOptionsToCompilerOptions(options: any): CompilerOptions {
3233}
3334
3435export function declareBuild ( program : Command ) {
35- const command = BaseOptions . addAll ( program
36- . command ( 'build [infile...]' )
37- . description ( `Compile one or more source files or projects.` )
36+ const buildCommand = program
37+ . command ( 'build' )
38+ . option ( '--color' , 'Force colorization for log messages' )
39+ . option ( '--no-color' , 'No colorization for log messages; if both omitted, detects from console' )
40+
41+ // These options are only used with build file but are included here so that
42+ // they are visible in `kmc build --help`
43+ . option ( '-d, --debug' , 'Include debug information in output' )
44+ . option ( '-w, --compiler-warnings-as-errors' , 'Causes warnings to fail the build; overrides project-level warnings-as-errors option' )
45+ . option ( '-W, --no-compiler-warnings-as-errors' , 'Warnings do not fail the build; overrides project-level warnings-as-errors option' )
46+ . option ( '--no-compiler-version' , 'Exclude compiler version metadata from output' )
47+ . option ( '--no-warn-deprecated-code' , 'Turn off warnings for deprecated code styles' ) ;
48+
49+ BaseOptions . addAll ( buildCommand ) ;
50+
51+ buildCommand . command ( 'file [infile...]' , { isDefault : true } )
52+ . description ( `Compile one or more source files or projects ('file' subcommand is default).` )
3853 . addHelpText ( 'after' , `
3954Supported file types:
40- * folder: Keyman project in folder
41- * .kpj: Keyman project
42- * .kmn: Keyman keyboard
43- * .xml: LDML keyboard
44- * .model.ts: Keyman lexical model
45- * .kps: Keyman keyboard or lexical model package
55+ * folder: Keyman project in folder
56+ * .kpj: Keyman project
57+ * .kmn: Keyman keyboard
58+ * .xml: LDML keyboard
59+ * .model.ts: Keyman lexical model
60+ * .kps: Keyman keyboard or lexical model package
4661
4762File lists can be referenced with @filelist.txt.
4863
4964If no input file is supplied, kmc will build the current folder.` )
50- )
51- . option ( '-d, --debug' , 'Include debug information in output' )
52- . option ( '-w, --compiler-warnings-as-errors' , 'Causes warnings to fail the build; overrides project-level warnings-as-errors option' )
53- . option ( '-W, --no-compiler-warnings-as-errors' , 'Warnings do not fail the build; overrides project-level warnings-as-errors option' )
54- . option ( '--no-compiler-version' , 'Exclude compiler version metadata from output' )
55- . option ( '--no-warn-deprecated-code' , 'Turn off warnings for deprecated code styles' )
56- . option ( '--color' , 'Force colorization for log messages' )
57- . option ( '--no-color' , 'No colorization for log messages; if both omitted, detects from console' )
58- . action ( async ( filenames : string [ ] , options : any ) => {
59- options = commandOptionsToCompilerOptions ( options ) ;
65+
66+ . action ( async ( filenames : string [ ] , _options : any , commander : any ) => {
67+ const options = commandOptionsToCompilerOptions ( commander . optsWithGlobals ( ) ) ;
6068 const callbacks = new NodeCompilerCallbacks ( options ) ;
6169
6270 if ( ! filenames . length ) {
@@ -77,12 +85,12 @@ If no input file is supplied, kmc will build the current folder.`)
7785 }
7886 } ) ;
7987
80- command
88+ buildCommand
8189 . command ( 'ldml-test-data <infile>' )
8290 . description ( 'Convert LDML keyboard test .xml to .json' )
8391 . action ( buildTestData ) ;
8492
85- command
93+ buildCommand
8694 . command ( 'windows-package-installer <infile>' )
8795 . description ( 'Build an executable installer for Windows for a Keyman package' )
8896 . option ( '--msi <msiFilename>' , 'Location of keymandesktop.msi' )
0 commit comments