@@ -317,7 +317,7 @@ function checkValidChoiceOption(choice: any): choice is Choices {
317
317
return false ;
318
318
}
319
319
320
- export async function setup ( contest_id : string , options : { choice : Choices , force ?: boolean , contestDirnameFormat ?: string , taskDirnameFormat ?: string , template ?: string , tests ?: boolean } ) {
320
+ export async function setup ( contest_id : string , options : { choice : Choices , force ?: boolean , contestDirnameFormat ?: string , taskDirnameFormat ?: string , template ?: string | boolean , tests ?: boolean } ) {
321
321
try {
322
322
const { contest} = await init ( contest_id , options ) ;
323
323
console . log ( `create project of ${ contest . title } ` ) ;
@@ -327,7 +327,7 @@ export async function setup(contest_id: string, options: { choice: Choices, forc
327
327
}
328
328
}
329
329
330
- export async function add ( options : { choice ?: Choices | boolean , force ?: boolean , taskDirnameFormat ?: string , template ?: string , tests ?: boolean } ) {
330
+ export async function add ( options : { choice ?: Choices | boolean , force ?: boolean , taskDirnameFormat ?: string , template ?: string | boolean , tests ?: boolean } ) {
331
331
try {
332
332
const { path, data} = await findProjectJSON ( ) ;
333
333
const { contest, tasks} = data ;
@@ -344,9 +344,17 @@ export async function add(options: { choice?: Choices | boolean, force?: boolean
344
344
}
345
345
return await selectTasks ( tasks , c , options . force ) ;
346
346
} ) ( options . choice ) ;
347
- const template = options . template !== undefined ? ( await getTemplate ( options . template ) . catch ( ( e ) => {
348
- throw new Error ( `Failed to load template "${ options . template } ".\n ${ e } ` ) ;
349
- } ) ) : undefined ;
347
+ const template = await ( async t => {
348
+ // --no-templateオプションが指定された場合は何も選ばない
349
+ if ( t === false ) return undefined ;
350
+ // 未指定の場合はコンフィグよりデフォルト値を取得
351
+ if ( t === undefined || t === true ) t = ( await getConfig ( ) ) . get ( "default-template" ) as string | undefined ;
352
+ // デフォルト値も指定されていなければ何も選ばない
353
+ if ( t === undefined ) return undefined ;
354
+ return await getTemplate ( t ) . catch ( ( e ) => {
355
+ throw new Error ( `Failed to load template "${ t } ".\n ${ e } ` ) ;
356
+ } ) ;
357
+ } ) ( options . template ) ;
350
358
// 更新があった問題の数を数えておく
351
359
let count = 0 ;
352
360
for ( const { index, task} of choices ) {
0 commit comments