From df2b19567bedd27f45f8b0bb62b3b40a6309e163 Mon Sep 17 00:00:00 2001 From: Icen Date: Fri, 22 Jul 2022 20:58:29 +0100 Subject: [PATCH 1/2] Added whether the gist is public or secret. Added the colour red to public and the colour green to secret --- pkg/cmd/gist/create/create.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/gist/create/create.go b/pkg/cmd/gist/create/create.go index 1122bdb7d..f61da9d70 100644 --- a/pkg/cmd/gist/create/create.go +++ b/pkg/cmd/gist/create/create.go @@ -115,6 +115,7 @@ func createRun(opts *CreateOptions) error { return fmt.Errorf("failed to collect files for posting: %w", err) } + cs := opts.IO.ColorScheme() gistName := guessGistName(files) processMessage := "Creating gist..." @@ -125,11 +126,13 @@ func createRun(opts *CreateOptions) error { } else { processMessage = fmt.Sprintf("Creating gist %s", gistName) } - completionMessage = fmt.Sprintf("Created gist %s", gistName) + if opts.Public { + completionMessage = fmt.Sprintf("Created %s gist %s", cs.Red("public"), gistName) + } else { + completionMessage = fmt.Sprintf("Created %s gist %s", cs.Green("secret"), gistName) + } } - cs := opts.IO.ColorScheme() - errOut := opts.IO.ErrOut fmt.Fprintf(errOut, "%s %s\n", cs.Gray("-"), processMessage) From 7f2bbf20ccefaf170c578293d9ad0d213cd25585 Mon Sep 17 00:00:00 2001 From: Icen Date: Fri, 22 Jul 2022 21:18:38 +0100 Subject: [PATCH 2/2] Changed the create_test.go accordingly --- pkg/cmd/gist/create/create_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/gist/create/create_test.go b/pkg/cmd/gist/create/create_test.go index f7bf8e7bb..4c5ee43e6 100644 --- a/pkg/cmd/gist/create/create_test.go +++ b/pkg/cmd/gist/create/create_test.go @@ -187,7 +187,7 @@ func Test_createRun(t *testing.T) { Filenames: []string{fixtureFile}, }, wantOut: "https://gist.github.com/aa5a315d61ae9438b18d\n", - wantStderr: "- Creating gist fixture.txt\n✓ Created gist fixture.txt\n", + wantStderr: "- Creating gist fixture.txt\n✓ Created public gist fixture.txt\n", wantErr: false, wantParams: map[string]interface{}{ "description": "", @@ -208,7 +208,7 @@ func Test_createRun(t *testing.T) { Filenames: []string{fixtureFile}, }, wantOut: "https://gist.github.com/aa5a315d61ae9438b18d\n", - wantStderr: "- Creating gist fixture.txt\n✓ Created gist fixture.txt\n", + wantStderr: "- Creating gist fixture.txt\n✓ Created secret gist fixture.txt\n", wantErr: false, wantParams: map[string]interface{}{ "description": "an incredibly interesting gist", @@ -229,7 +229,7 @@ func Test_createRun(t *testing.T) { }, stdin: "cool stdin content", wantOut: "https://gist.github.com/aa5a315d61ae9438b18d\n", - wantStderr: "- Creating gist with multiple files\n✓ Created gist fixture.txt\n", + wantStderr: "- Creating gist with multiple files\n✓ Created secret gist fixture.txt\n", wantErr: false, wantParams: map[string]interface{}{ "description": "", @@ -295,7 +295,7 @@ func Test_createRun(t *testing.T) { Filenames: []string{fixtureFile}, }, wantOut: "Opening gist.github.com/aa5a315d61ae9438b18d in your browser.\n", - wantStderr: "- Creating gist fixture.txt\n✓ Created gist fixture.txt\n", + wantStderr: "- Creating gist fixture.txt\n✓ Created secret gist fixture.txt\n", wantErr: false, wantBrowse: "https://gist.github.com/aa5a315d61ae9438b18d", wantParams: map[string]interface{}{