Skip to content

Commit f05f122

Browse files
authored
feat: update slog to use logfmt (#7477)
1 parent 0f4717e commit f05f122

19 files changed

+92
-54
lines changed

cli/root_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"strings"
1414
"testing"
1515

16+
"github.com/charmbracelet/lipgloss"
17+
"github.com/muesli/termenv"
1618
"github.com/stretchr/testify/assert"
1719
"github.com/stretchr/testify/require"
1820

@@ -33,8 +35,17 @@ var updateGoldenFiles = flag.Bool("update", false, "update .golden files")
3335

3436
var timestampRegex = regexp.MustCompile(`(?i)\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d+)?Z`)
3537

38+
// We need to override the global color profile.
39+
//
40+
//nolint:tparallel,paralleltest
3641
func TestCommandHelp(t *testing.T) {
37-
t.Parallel()
42+
ogColorProfile := lipgloss.ColorProfile()
43+
// ANSI256 escape codes are far easier for humans to parse in a diff,
44+
// but TrueColor is probably more popular with modern terminals.
45+
lipgloss.SetColorProfile(termenv.ANSI)
46+
t.Cleanup(func() {
47+
lipgloss.SetColorProfile(ogColorProfile)
48+
})
3849
rootClient, replacements := prepareTestData(t)
3950

4051
type testCase struct {

cli/testdata/coder_--help.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Usage: coder [global-flags] <subcommand>
33
Coder v0.0.0-devel — A tool for provisioning self-hosted development environments with Terraform.
44
- Start a Coder server:
55

6-
$ coder server
6+
 $ coder server 
77

88
- Get started by creating a template from an example:
99

10-
$ coder templates init
10+
 $ coder templates init 
1111

1212
Subcommands
1313
config-ssh Add an SSH Host entry for your workspaces "ssh

cli/testdata/coder_config-ssh_--help.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Add an SSH Host entry for your workspaces "ssh coder.workspace"
55
- You can use -o (or --ssh-option) so set SSH options to be used for all your
66
workspaces:
77

8-
$ coder config-ssh -o ForwardAgent=yes
8+
 $ coder config-ssh -o ForwardAgent=yes 
99

1010
- You can use --dry-run (or -n) to see the changes that would be made:
1111

12-
$ coder config-ssh --dry-run
12+
 $ coder config-ssh --dry-run 
1313

1414
Options
1515
-n, --dry-run bool, $CODER_SSH_DRY_RUN

cli/testdata/coder_dotfiles_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Personalize your workspace by applying a canonical dotfiles repository
44

55
- Check out and install a dotfiles repository without prompts:
66

7-
$ coder dotfiles --yes git@github.com:example/dotfiles.git
7+
 $ coder dotfiles --yes git@github.com:example/dotfiles.git 
88

99
Options
1010
--symlink-dir string, $CODER_SYMLINK_DIR

cli/testdata/coder_port-forward_--help.golden

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ Aliases: tunnel
77
- Port forward a single TCP port from 1234 in the workspace to port 5678 on
88
your local machine:
99

10-
$ coder port-forward <workspace> --tcp 5678:1234
10+
 $ coder port-forward <workspace> --tcp 5678:1234 
1111

1212
- Port forward a single UDP port from port 9000 to port 9000 on your local
1313
machine:
1414

15-
$ coder port-forward <workspace> --udp 9000
15+
 $ coder port-forward <workspace> --udp 9000 
1616

1717
- Port forward multiple TCP ports and a UDP port:
1818

19-
$ coder port-forward <workspace> --tcp 8080:8080 --tcp 9000:3000 --udp 5353:53
19+
 $ coder port-forward <workspace> --tcp 8080:8080 --tcp 9000:3000 --udp 5353:53 
2020

2121
- Port forward multiple ports (TCP or UDP) in condensed syntax:
2222

23-
$ coder port-forward <workspace> --tcp 8080,9000:3000,9090-9092,10000-10002:10010-10012
23+
 $ coder port-forward <workspace> --tcp 8080,9000:3000,9090-9092,10000-10002:10010-10012 
2424

2525
Options
2626
-p, --tcp string-array, $CODER_PORT_FORWARD_TCP

cli/testdata/coder_schedule_override-stop_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Override the stop time of a currently running workspace instance.
66
* The new stop time must be at least 30 minutes in the future.
77
* The workspace template may restrict the maximum workspace runtime.
88

9-
$ coder schedule override-stop my-workspace 90m
9+
 $ coder schedule override-stop my-workspace 90m 
1010

1111
---
1212
Run `coder --help` for a list of global options.

cli/testdata/coder_schedule_start_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Schedule format: <start-time> [day-of-week] [location].
1414

1515
- Set the workspace to start at 9:30am (in Dublin) from Monday to Friday:
1616

17-
$ coder schedule start my-workspace 9:30AM Mon-Fri Europe/Dublin
17+
 $ coder schedule start my-workspace 9:30AM Mon-Fri Europe/Dublin 
1818

1919
---
2020
Run `coder --help` for a list of global options.

cli/testdata/coder_schedule_stop_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ When enabling scheduled stop, enter a duration in one of the following formats:
1515
* 2m (2 minutes)
1616
* 2 (2 minutes)
1717

18-
$ coder schedule stop my-workspace 2h30m
18+
 $ coder schedule stop my-workspace 2h30m 
1919

2020
---
2121
Run `coder --help` for a list of global options.

cli/testdata/coder_templates_--help.golden

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ Aliases: template
77
Templates are written in standard Terraform and describe the infrastructure for workspaces
88
- Create a template for developers to create workspaces:
99

10-
$ coder templates create
10+
 $ coder templates create 
1111

1212
- Make changes to your template, and plan the changes:
1313

14-
$ coder templates plan my-template
14+
 $ coder templates plan my-template 
1515

1616
- Push an update to the template. Your developers can update their workspaces:
1717

18-
$ coder templates push my-template
18+
 $ coder templates push my-template 
1919

2020
Subcommands
2121
create Create a template from the current directory or as specified by

cli/testdata/coder_templates_versions_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Aliases: version
66

77
- List versions of a specific template:
88

9-
$ coder templates versions list my-template
9+
 $ coder templates versions list my-template 
1010

1111
Subcommands
1212
list List all the versions of the specified template

0 commit comments

Comments
 (0)