Skip to content

Commit fb6f3eb

Browse files
committed
Print username and game URL seperately in session show command
1 parent 33876c1 commit fb6f3eb

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

cmd/new.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var newCmd = &cobra.Command{
4949
abort(fmt.Errorf("project '%s' already exists.", projectName))
5050
}
5151

52-
err = os.MkdirAll(projectName, 0755)
52+
err = os.MkdirAll(projectName, 0o755)
5353
abort(err)
5454
err = os.Chdir(projectName)
5555
abort(err)
@@ -251,7 +251,7 @@ func readme(projectName string) error {
251251

252252
fileContent := fmt.Sprintf("# %s", projectName)
253253

254-
return os.WriteFile("README.md", []byte(fileContent), 0644)
254+
return os.WriteFile("README.md", []byte(fileContent), 0o644)
255255
}
256256

257257
//go:embed templates/licenses/MIT.tmpl
@@ -314,6 +314,10 @@ func license() error {
314314

315315
if _, err := os.Stat("README.md"); err == nil {
316316
err = writeReadmeLicense(licenseReadmeTemplate, external.GetUsername(), time.Now().Year())
317+
if err != nil {
318+
cli.Error("Failed to write license into README.md")
319+
return nil
320+
}
317321
}
318322

319323
return nil
@@ -342,7 +346,7 @@ func writeLicense(templateText, username string, year int) error {
342346
}
343347

344348
func writeReadmeLicense(templateText, username string, year int) error {
345-
readme, err := os.OpenFile("README.md", os.O_APPEND|os.O_WRONLY, 0755)
349+
readme, err := os.OpenFile("README.md", os.O_APPEND|os.O_WRONLY, 0o755)
346350
if err != nil {
347351
return fmt.Errorf("Failed to append license text to README.")
348352
}
@@ -367,7 +371,7 @@ func writeReadmeLicense(templateText, username string, year int) error {
367371
}
368372

369373
func execTemplate(templateText, path string, data any) error {
370-
err := os.MkdirAll(filepath.Join(filepath.Dir(path)), 0755)
374+
err := os.MkdirAll(filepath.Join(filepath.Dir(path)), 0o755)
371375
if err != nil {
372376
return err
373377
}

cmd/session_show.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package cmd
22

33
import (
4-
"fmt"
5-
64
"github.com/mattn/go-colorable"
75
"github.com/spf13/cobra"
86
)
@@ -17,7 +15,8 @@ var sessionShowCmd = &cobra.Command{
1715
abortf("Failed to load session: %s", err)
1816

1917
out := colorable.NewColorableStdout()
20-
printInfoProperty(out, "Name", fmt.Sprintf("%s@%s", session.Username, session.GameURL), 14)
18+
printInfoProperty(out, "Game URL", session.GameURL, 14)
19+
printInfoProperty(out, "Username", session.Username, 14)
2120
printInfoProperty(out, "Game ID", session.GameId, 14)
2221
printInfoProperty(out, "Player ID", session.PlayerId, 14)
2322
printInfoProperty(out, "Player Secret", session.PlayerSecret, 14)

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/code-game-project/codegame-cli
33
go 1.18
44

55
require (
6-
github.com/Bananenpro/cli v0.2.2
6+
github.com/Bananenpro/cli v0.3.0
77
github.com/adrg/xdg v0.4.0
8-
github.com/code-game-project/go-utils v0.2.8
8+
github.com/code-game-project/go-utils v0.2.9
99
github.com/gomarkdown/markdown v0.0.0-20220731190611-dcdaee8e7a53
1010
github.com/google/uuid v1.3.0
1111
github.com/mattn/go-colorable v0.1.12

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ github.com/AlecAivazis/survey/v2 v2.3.5 h1:A8cYupsAZkjaUmhtTYv3sSqc7LO5mp1XDfqe5
22
github.com/AlecAivazis/survey/v2 v2.3.5/go.mod h1:4AuI9b7RjAR+G7v9+C4YSlX/YL3K3cWNXgWXOhllqvI=
33
github.com/Bananenpro/cli v0.2.2 h1:7nMlgMGMT1rxkuqCiJuo/Jd89HTnw9psE3h/vQW57nk=
44
github.com/Bananenpro/cli v0.2.2/go.mod h1:JBXpIAXo/D0rlsfgCViQBicjcJY6UWUldmxvKM+ijRc=
5+
github.com/Bananenpro/cli v0.3.0 h1:gQOzc22yv+rePT0nRYva1ccdva3hTGyUwrGdcnXqchU=
6+
github.com/Bananenpro/cli v0.3.0/go.mod h1:JBXpIAXo/D0rlsfgCViQBicjcJY6UWUldmxvKM+ijRc=
57
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
68
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
79
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
810
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
911
github.com/code-game-project/go-utils v0.2.8 h1:f6ZvORWmlf8uZnCSAhLJ23MdA5dGvcAPkijTLfbv+B4=
1012
github.com/code-game-project/go-utils v0.2.8/go.mod h1:kQ6kH9XDzdM2pnJUI1lw61Gp8XOams/E2dKABa1mBI8=
13+
github.com/code-game-project/go-utils v0.2.9 h1:ezaxxLBAQRwFnIXso+zKPL7AJnuAMIcMwrhLruoyOa8=
14+
github.com/code-game-project/go-utils v0.2.9/go.mod h1:kQ6kH9XDzdM2pnJUI1lw61Gp8XOams/E2dKABa1mBI8=
1115
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
1216
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
1317
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=

0 commit comments

Comments
 (0)