Skip to content

Commit d82c0f9

Browse files
committed
fix: use centralized shouldShowSpinner() for all spinner checks
Updated bulk.ts to use the centralized shouldShowSpinner() function instead of directly checking Deno.stdout.isTerminal(). This ensures progress display during bulk operations also respects the NO_COLOR environment variable. Fixes #113
1 parent f574e46 commit d82c0f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+281
-109
lines changed

src/commands/document/document-create.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export const createCommand = new Command()
4141
.option("--issue <issue:string>", "Attach to issue (identifier like TC-123)")
4242
.option("--icon <icon:string>", "Document icon (emoji)")
4343
.option("-i, --interactive", "Interactive mode with prompts")
44-
.option("--no-color", "Disable colored output")
4544
.action(
4645
async ({
4746
title,
@@ -51,7 +50,6 @@ export const createCommand = new Command()
5150
issue,
5251
icon,
5352
interactive,
54-
color: _colorEnabled,
5553
}) => {
5654
const client = getGraphQLClient()
5755

src/commands/document/document-delete.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const deleteCommand = new Command()
2020
.alias("d")
2121
.arguments("[documentId:string]")
2222
.option("-y, --yes", "Skip confirmation prompt")
23-
.option("--no-color", "Disable colored output")
2423
.option(
2524
"--bulk <ids...:string>",
2625
"Delete multiple documents by slug or ID",
@@ -32,7 +31,7 @@ export const deleteCommand = new Command()
3231
.option("--bulk-stdin", "Read document slugs/IDs from stdin")
3332
.action(
3433
async (
35-
{ yes, color: colorEnabled, bulk, bulkFile, bulkStdin },
34+
{ yes, bulk, bulkFile, bulkStdin },
3635
documentId,
3736
) => {
3837
const client = getGraphQLClient()
@@ -44,7 +43,6 @@ export const deleteCommand = new Command()
4443
bulkFile,
4544
bulkStdin,
4645
yes,
47-
colorEnabled,
4846
})
4947
return
5048
}
@@ -57,15 +55,15 @@ export const deleteCommand = new Command()
5755
Deno.exit(1)
5856
}
5957

60-
await handleSingleDelete(client, documentId, { yes, colorEnabled })
58+
await handleSingleDelete(client, documentId, { yes })
6159
},
6260
)
6361

6462
async function handleSingleDelete(
6563
// deno-lint-ignore no-explicit-any
6664
client: any,
6765
documentId: string,
68-
options: { yes?: boolean; colorEnabled?: boolean },
66+
options: { yes?: boolean },
6967
): Promise<void> {
7068
const { yes } = options
7169

@@ -144,10 +142,9 @@ async function handleBulkDelete(
144142
bulkFile?: string
145143
bulkStdin?: boolean
146144
yes?: boolean
147-
colorEnabled?: boolean
148145
},
149146
): Promise<void> {
150-
const { yes, colorEnabled = true } = options
147+
const { yes } = options
151148

152149
// Collect all IDs
153150
const ids = await collectBulkIds({
@@ -245,14 +242,12 @@ async function handleBulkDelete(
245242
// Execute bulk operation
246243
const summary = await executeBulkOperations(ids, deleteOperation, {
247244
showProgress: true,
248-
colorEnabled,
249245
})
250246

251247
// Print summary
252248
printBulkSummary(summary, {
253249
entityName: "document",
254250
operationName: "deleted",
255-
colorEnabled,
256251
showDetails: true,
257252
})
258253

src/commands/document/document-list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Command } from "@cliffy/command"
22
import { gql } from "../../__codegen__/gql.ts"
33
import { getGraphQLClient } from "../../utils/graphql.ts"
44
import { getTimeAgo, padDisplay } from "../../utils/display.ts"
5+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
56

67
const ListDocuments = gql(`
78
query ListDocuments($filter: DocumentFilter, $first: Int) {
@@ -42,7 +43,7 @@ export const listCommand = new Command()
4243
.option("--limit <limit:number>", "Limit results", { default: 50 })
4344
.action(async ({ project, issue, json, limit }) => {
4445
const { Spinner } = await import("@std/cli/unstable-spinner")
45-
const showSpinner = Deno.stdout.isTerminal() && !json
46+
const showSpinner = shouldShowSpinner() && !json
4647
const spinner = showSpinner ? new Spinner() : null
4748
spinner?.start()
4849

src/commands/document/document-update.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ export const updateCommand = new Command()
9999
)
100100
.option("--icon <icon:string>", "New icon (emoji)")
101101
.option("-e, --edit", "Open current content in $EDITOR for editing")
102-
.option("--no-color", "Disable colored output")
103102
.action(
104103
async (
105-
{ title, content, contentFile, icon, edit, color: _colorEnabled },
104+
{ title, content, contentFile, icon, edit },
106105
documentId,
107106
) => {
108107
const client = getGraphQLClient()

src/commands/document/document-view.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { open } from "@opensrc/deno-open"
44
import { gql } from "../../__codegen__/gql.ts"
55
import { getGraphQLClient } from "../../utils/graphql.ts"
66
import { formatRelativeTime } from "../../utils/display.ts"
7+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
78

89
const GetDocument = gql(`
910
query GetDocument($id: String!) {
@@ -41,7 +42,7 @@ export const viewCommand = new Command()
4142
.option("--json", "Output full document as JSON")
4243
.action(async ({ raw, web, json }, id) => {
4344
const { Spinner } = await import("@std/cli/unstable-spinner")
44-
const showSpinner = Deno.stdout.isTerminal() && !raw && !json
45+
const showSpinner = shouldShowSpinner() && !raw && !json
4546
const spinner = showSpinner ? new Spinner() : null
4647
spinner?.start()
4748

src/commands/initiative-update/initiative-update-create.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { gql } from "../../__codegen__/gql.ts"
44
import { getGraphQLClient } from "../../utils/graphql.ts"
55
import { getEditor, openEditor } from "../../utils/editor.ts"
66
import { readIdsFromStdin } from "../../utils/bulk.ts"
7+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
78

89
const HEALTH_VALUES = ["onTrack", "atRisk", "offTrack"] as const
910
type HealthValue = (typeof HEALTH_VALUES)[number]
@@ -101,10 +102,9 @@ export const createCommand = new Command()
101102
"Health status (onTrack, atRisk, offTrack)",
102103
)
103104
.option("-i, --interactive", "Interactive mode with prompts")
104-
.option("--no-color", "Disable colored output")
105105
.action(
106106
async (
107-
{ body, bodyFile, health, interactive, color: colorEnabled },
107+
{ body, bodyFile, health, interactive },
108108
initiativeId,
109109
) => {
110110
const client = getGraphQLClient()
@@ -152,7 +152,6 @@ export const createCommand = new Command()
152152
initiativeId: resolvedId,
153153
body: result.body,
154154
health: result.health,
155-
colorEnabled: colorEnabled !== false,
156155
})
157156
return
158157
}
@@ -211,7 +210,6 @@ export const createCommand = new Command()
211210
initiativeId: resolvedId,
212211
body: finalBody,
213212
health: validatedHealth,
214-
colorEnabled: colorEnabled !== false,
215213
})
216214
},
217215
)
@@ -293,13 +291,12 @@ async function createInitiativeUpdate(
293291
initiativeId: string
294292
body?: string
295293
health?: HealthValue
296-
colorEnabled: boolean
297294
},
298295
): Promise<void> {
299-
const { initiativeId, body, health, colorEnabled } = options
296+
const { initiativeId, body, health } = options
300297

301298
const { Spinner } = await import("@std/cli/unstable-spinner")
302-
const showSpinner = colorEnabled && Deno.stdout.isTerminal()
299+
const showSpinner = shouldShowSpinner()
303300
const spinner = showSpinner ? new Spinner() : null
304301
spinner?.start()
305302

src/commands/initiative-update/initiative-update-list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
padDisplay,
77
truncateText,
88
} from "../../utils/display.ts"
9+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
910

1011
/**
1112
* Resolve initiative ID from UUID, slug, or name
@@ -91,7 +92,7 @@ export const listCommand = new Command()
9192
.option("--limit <limit:number>", "Limit results", { default: 10 })
9293
.action(async ({ json, limit }, initiativeId) => {
9394
const { Spinner } = await import("@std/cli/unstable-spinner")
94-
const showSpinner = Deno.stdout.isTerminal() && !json
95+
const showSpinner = shouldShowSpinner() && !json
9596
const spinner = showSpinner ? new Spinner() : null
9697
spinner?.start()
9798

src/commands/initiative/initiative-add-project.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Command } from "@cliffy/command"
22
import { gql } from "../../__codegen__/gql.ts"
33
import { getGraphQLClient } from "../../utils/graphql.ts"
4+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
45

56
const AddProjectToInitiative = gql(`
67
mutation AddProjectToInitiative($input: InitiativeToProjectCreateInput!) {
@@ -176,10 +177,9 @@ export const addProjectCommand = new Command()
176177
.description("Link a project to an initiative")
177178
.arguments("<initiative:string> <project:string>")
178179
.option("--sort-order <sortOrder:number>", "Sort order within initiative")
179-
.option("--no-color", "Disable colored output")
180180
.action(
181181
async (
182-
{ sortOrder, color: colorEnabled },
182+
{ sortOrder },
183183
initiativeArg,
184184
projectArg,
185185
) => {
@@ -200,7 +200,7 @@ export const addProjectCommand = new Command()
200200
}
201201

202202
const { Spinner } = await import("@std/cli/unstable-spinner")
203-
const showSpinner = colorEnabled && Deno.stdout.isTerminal()
203+
const showSpinner = shouldShowSpinner()
204204
const spinner = showSpinner ? new Spinner() : null
205205
spinner?.start()
206206

src/commands/initiative/initiative-archive.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isBulkMode,
1010
printBulkSummary,
1111
} from "../../utils/bulk.ts"
12+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
1213

1314
interface InitiativeArchiveResult extends BulkOperationResult {
1415
name: string
@@ -19,7 +20,6 @@ export const archiveCommand = new Command()
1920
.description("Archive a Linear initiative")
2021
.arguments("[initiativeId:string]")
2122
.option("-y, --force", "Skip confirmation prompt")
22-
.option("--no-color", "Disable colored output")
2323
.option(
2424
"--bulk <ids...:string>",
2525
"Archive multiple initiatives by ID, slug, or name",
@@ -31,7 +31,7 @@ export const archiveCommand = new Command()
3131
.option("--bulk-stdin", "Read initiative IDs from stdin")
3232
.action(
3333
async (
34-
{ force, color: colorEnabled, bulk, bulkFile, bulkStdin },
34+
{ force, bulk, bulkFile, bulkStdin },
3535
initiativeId,
3636
) => {
3737
const client = getGraphQLClient()
@@ -43,7 +43,6 @@ export const archiveCommand = new Command()
4343
bulkFile,
4444
bulkStdin,
4545
force,
46-
colorEnabled,
4746
})
4847
return
4948
}
@@ -56,17 +55,17 @@ export const archiveCommand = new Command()
5655
Deno.exit(1)
5756
}
5857

59-
await handleSingleArchive(client, initiativeId, { force, colorEnabled })
58+
await handleSingleArchive(client, initiativeId, { force })
6059
},
6160
)
6261

6362
async function handleSingleArchive(
6463
// deno-lint-ignore no-explicit-any
6564
client: any,
6665
initiativeId: string,
67-
options: { force?: boolean; colorEnabled?: boolean },
66+
options: { force?: boolean },
6867
): Promise<void> {
69-
const { force, colorEnabled } = options
68+
const { force } = options
7069

7170
// Resolve initiative ID
7271
const resolvedId = await resolveInitiativeId(client, initiativeId)
@@ -126,7 +125,7 @@ async function handleSingleArchive(
126125
}
127126

128127
const { Spinner } = await import("@std/cli/unstable-spinner")
129-
const showSpinner = colorEnabled && Deno.stdout.isTerminal()
128+
const showSpinner = shouldShowSpinner()
130129
const spinner = showSpinner ? new Spinner() : null
131130
spinner?.start()
132131

@@ -165,10 +164,9 @@ async function handleBulkArchive(
165164
bulkFile?: string
166165
bulkStdin?: boolean
167166
force?: boolean
168-
colorEnabled?: boolean
169167
},
170168
): Promise<void> {
171-
const { force, colorEnabled = true } = options
169+
const { force } = options
172170

173171
// Collect all IDs
174172
const ids = await collectBulkIds({
@@ -280,14 +278,12 @@ async function handleBulkArchive(
280278
// Execute bulk operation
281279
const summary = await executeBulkOperations(ids, archiveOperation, {
282280
showProgress: true,
283-
colorEnabled,
284281
})
285282

286283
// Print summary
287284
printBulkSummary(summary, {
288285
entityName: "initiative",
289286
operationName: "archived",
290-
colorEnabled,
291287
showDetails: true,
292288
})
293289

src/commands/initiative/initiative-create.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { gql } from "../../__codegen__/gql.ts"
44
import type { InitiativeStatus } from "../../__codegen__/graphql.ts"
55
import { getGraphQLClient } from "../../utils/graphql.ts"
66
import { lookupUserId } from "../../utils/linear.ts"
7+
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
78

89
const CreateInitiative = gql(`
910
mutation CreateInitiative($input: InitiativeCreateInput!) {
@@ -63,7 +64,6 @@ export const createCommand = new Command()
6364
"-i, --interactive",
6465
"Interactive mode (default if no flags provided)",
6566
)
66-
.option("--no-color", "Disable colored output")
6767
.action(async (options) => {
6868
const {
6969
name: providedName,
@@ -76,9 +76,6 @@ export const createCommand = new Command()
7676
interactive: interactiveFlag,
7777
} = options
7878

79-
// Note: --no-color flag is separate from --color (hex color) flag
80-
// When checking showSpinner, we use Deno.stdout.isTerminal() as the primary check
81-
8279
const client = getGraphQLClient()
8380
const icon = providedIcon
8481

@@ -228,7 +225,7 @@ export const createCommand = new Command()
228225
}
229226

230227
const { Spinner } = await import("@std/cli/unstable-spinner")
231-
const showSpinner = Deno.stdout.isTerminal()
228+
const showSpinner = shouldShowSpinner()
232229
const spinner = showSpinner ? new Spinner() : null
233230
spinner?.start()
234231

0 commit comments

Comments
 (0)