@@ -3,7 +3,7 @@ import { LogType, fsa } from '@basemaps/shared';
33import { CliId , CliInfo } from '@basemaps/shared/build/cli/info.js' ;
44import { CogTiff , TiffTag } from '@cogeotiff/core' ;
55import { Metrics } from '@linzjs/metrics' ;
6- import { command , flag , restPositionals } from 'cmd-ts' ;
6+ import { command , flag , option , optional , restPositionals } from 'cmd-ts' ;
77import { mkdir , rm } from 'fs/promises' ;
88import { tmpdir } from 'os' ;
99import { StacAsset , StacCollection } from 'stac-ts' ;
@@ -13,7 +13,7 @@ import { HashTransform } from '../../hash.stream.js';
1313import { getLogger , logArguments } from '../../log.js' ;
1414import { gdalBuildCog , gdalBuildVrt , gdalBuildVrtWarp } from '../gdal.command.js' ;
1515import { GdalRunner } from '../gdal.runner.js' ;
16- import { Url } from '../parsers.js' ;
16+ import { Url , UrlArrayJsonFile } from '../parsers.js' ;
1717import { CogifyCreationOptions , CogifyStacItem , getCutline , getSources } from '../stac.js' ;
1818
1919// FIXME: HACK @cogeotiff /core to include the Lerc tiff tag
@@ -61,15 +61,24 @@ export const BasemapsCogifyCreateCommand = command({
6161 description : 'Create a COG from a covering configuration' ,
6262 args : {
6363 ...logArguments ,
64- path : restPositionals ( { type : Url , displayName : 'path' , description : 'Path to item json ' } ) ,
64+ path : restPositionals ( { type : Url , displayName : 'path' , description : 'Path to covering configuration ' } ) ,
6565 force : flag ( { long : 'force' , description : 'Overwrite existing tiff files' } ) ,
66+ fromFile : option ( {
67+ type : optional ( UrlArrayJsonFile ) ,
68+ long : 'from-file' ,
69+ description :
70+ 'Path to JSON file containing array of paths to covering configurations. ' +
71+ 'File must be an array of objects with key "path" and value of a path to a covering configuration.' ,
72+ } ) ,
6673 } ,
6774
6875 async handler ( args ) {
6976 const metrics = new Metrics ( ) ;
7077 const logger = getLogger ( this , args ) ;
7178
72- const toCreate = await Promise . all ( args . path . map ( async ( p ) => loadItem ( p , logger ) ) ) ;
79+ const paths = args . fromFile != null ? args . path . concat ( args . fromFile ) : args . path ;
80+
81+ const toCreate = await Promise . all ( paths . map ( async ( p ) => loadItem ( p , logger ) ) ) ;
7382 // // Filter out any missing items, also excluding items which already have COGs created
7483 const filtered = toCreate . filter ( ( f ) => {
7584 if ( f == null ) return false ;
0 commit comments