Skip to content

Commit 7d922df

Browse files
committed
Dedicated style for resource names
1 parent f1e3e88 commit 7d922df

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

internal/pkg/cli/command/index/configure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ func runConfigureIndexCmd(options configureIndexOptions, cmd *cobra.Command, arg
6969
}
7070

7171
describeCommand := pcio.Sprintf("pc index describe %s", idx.Name)
72-
msg.SuccessMsg("Index %s configured successfully. Run %s to check status. \n\n", style.Emphasis(idx.Name), style.Code(describeCommand))
72+
msg.SuccessMsg("Index %s configured successfully. Run %s to check status. \n\n", style.ResourceName(idx.Name), style.Code(describeCommand))
7373
presenters.PrintDescribeIndexTable(idx)
7474
}

internal/pkg/cli/command/index/create.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,12 @@ func printCreatePreview(options createIndexOptions, idxType indexType) {
288288

289289
// Print title
290290
pcio.Println()
291-
pcio.Printf("%s\n\n", style.Heading(pcio.Sprintf("Creating %s index %s with the following configuration:",
292-
style.Emphasis(string(idxType)),
293-
style.Code(options.name))))
291+
pcio.Printf("%s\n\n",
292+
pcio.Sprintf("Creating %s index %s with the following configuration:",
293+
style.Emphasis(string(idxType)),
294+
style.ResourceName(options.name),
295+
),
296+
)
294297

295298
// Use the specialized index table without status info (second column set)
296299
presenters.PrintDescribeIndexTable(mockIndex)
@@ -304,7 +307,7 @@ func renderSuccessOutput(idx *pinecone.Index, options createIndexOptions) {
304307
}
305308

306309
describeCommand := pcio.Sprintf("pc index describe %s", idx.Name)
307-
msg.SuccessMsg("Index %s created successfully. Run %s to check status. \n\n", style.Emphasis(idx.Name), style.Code(describeCommand))
310+
msg.SuccessMsg("Index %s created successfully. Run %s to check status. \n\n", style.ResourceName(idx.Name), style.Code(describeCommand))
308311
presenters.PrintDescribeIndexTable(idx)
309312
}
310313

internal/pkg/cli/command/index/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewDeleteCmd() *cobra.Command {
3131

3232
// Ask for user confirmation
3333
msg.WarnMsgMultiLine(
34-
pcio.Sprintf("This will delete the index %s and all its data.", style.Emphasis(options.name)),
34+
pcio.Sprintf("This will delete the index %s and all its data.", style.ResourceName(options.name)),
3535
"This action cannot be undone.",
3636
)
3737
question := "Are you sure you want to proceed with the deletion?"
@@ -49,7 +49,7 @@ func NewDeleteCmd() *cobra.Command {
4949
exit.Error(err)
5050
}
5151

52-
msg.SuccessMsg("Index %s deleted.\n", style.Emphasis(options.name))
52+
msg.SuccessMsg("Index %s deleted.\n", style.ResourceName(options.name))
5353
},
5454
}
5555

internal/pkg/cli/command/login/whoami.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewWhoAmICmd() *cobra.Command {
3232
exit.Error(pcio.Errorf("error parsing claims from access token: %s", err))
3333
return
3434
}
35-
msg.InfoMsg("Logged in as " + style.Emphasis(claims.Email))
35+
msg.InfoMsg("Logged in as " + style.ResourceName(claims.Email))
3636
},
3737
}
3838

internal/pkg/utils/presenters/table.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ func PrintDescribeIndexTableWithIndexAttributesGroups(idx *pinecone.Index, group
171171
fmt.Println()
172172
}
173173
}
174+
// Add spacing after the last row
175+
fmt.Println()
174176
}
175177

176178
// ColorizeState applies appropriate styling to index state

internal/pkg/utils/style/functions.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ func Code(s string) string {
4242
return CodeStyle().Render(s)
4343
}
4444

45+
func ResourceName(s string) string {
46+
if color.NoColor {
47+
// Add backticks for code formatting if color is disabled
48+
return "`" + s + "`"
49+
}
50+
return HeavyEmphasisStyle().Render(s)
51+
}
52+
4553
func URL(s string) string {
4654
return URLStyle().Render(s)
4755
}

0 commit comments

Comments
 (0)