1- import { readFile } from 'node:fs/promises'
21import { createInterface } from 'node:readline/promises'
32import type { TwistApi } from '@doist/twist-sdk'
43import { Command } from 'commander'
@@ -10,7 +9,6 @@ import { resolveThreadId } from '../../lib/refs.js'
109import { pluralize } from './helpers.js'
1110
1211type ThreadMutationOptions = MutationOptions & {
13- fromFile ?: string
1412 yes ?: boolean
1513 json ?: boolean
1614}
@@ -155,25 +153,6 @@ async function getUnreadThreadIds(client: TwistApi, workspaceId: number): Promis
155153 return new Set ( unread . map ( ( item ) => item . threadId ) )
156154}
157155
158- async function loadThreadRefs (
159- fromArgs : string [ ] | undefined ,
160- fromFilePath ?: string ,
161- ) : Promise < string [ ] > {
162- const refs = [ ...( fromArgs ?? [ ] ) ]
163-
164- if ( ! fromFilePath ) {
165- return refs
166- }
167-
168- const fileContent = await readFile ( fromFilePath , 'utf8' )
169- const fromFile = fileContent
170- . split ( / \r ? \n / )
171- . map ( ( line ) => line . trim ( ) )
172- . filter ( ( line ) => line !== '' && ! line . startsWith ( '#' ) )
173-
174- return [ ...refs , ...fromFile ]
175- }
176-
177156async function confirmBulkMutation ( count : number , mutationLabel : string ) : Promise < boolean > {
178157 if ( count <= 1 ) {
179158 return true
@@ -282,10 +261,10 @@ async function executeThreadMutation(
282261 mutation : ThreadMutation ,
283262 mutationLabel : string ,
284263) : Promise < void > {
285- const inputRefs = await loadThreadRefs ( refs , options . fromFile )
264+ const inputRefs = [ ... ( refs ?? [ ] ) ]
286265
287266 if ( inputRefs . length === 0 ) {
288- throw new Error ( 'No thread references provided. Pass refs and/or --from-file. ' )
267+ throw new Error ( 'No thread references provided.' )
289268 }
290269
291270 if ( inputRefs . length > 1 && ! options . dryRun && ! options . yes ) {
@@ -361,7 +340,6 @@ async function executeThreadMutation(
361340
362341export function withThreadMutationOptions ( command : Command ) : Command {
363342 return command
364- . option ( '--from-file <path>' , 'Read thread refs from file (one ref per line)' )
365343 . option ( '--yes' , 'Skip confirmation for bulk operations' )
366344 . option ( '--dry-run' , 'Show what would happen without executing' )
367345 . option ( '--json' , 'Output mutation results as JSON' )
0 commit comments