fix: implement godot's suggestions on app comments
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d32b44aedd
commit
6a2470db54
10
cmd/root.go
10
cmd/root.go
@ -10,10 +10,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// appName is the name of the app
|
||||
// appName is the name of the app.
|
||||
const appName = "go-xkcdreader"
|
||||
|
||||
// Root is the main go-xkcdreader command
|
||||
// Root is the main go-xkcdreader command.
|
||||
var Root = &cobra.Command{
|
||||
Use: appName,
|
||||
Short: "an offline-capable xkcd webcomic reader written in Go",
|
||||
@ -24,12 +24,12 @@ var Root = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
// GetAppName returns the name of the application
|
||||
// GetAppName returns the name of the application.
|
||||
func GetAppName() string {
|
||||
return appName
|
||||
}
|
||||
|
||||
// Execute is the entrypoint of cobra's poison
|
||||
// Execute is the entrypoint of cobra's poison.
|
||||
func Execute() {
|
||||
if err := Root.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@ -38,7 +38,7 @@ func Execute() {
|
||||
}
|
||||
|
||||
// help redefines the original help func, essentially adding a way to exit the
|
||||
// application properly after showing help message
|
||||
// application properly after showing help message.
|
||||
func help(*cobra.Command, []string) {
|
||||
err := Root.Usage()
|
||||
if err != nil {
|
||||
|
@ -25,7 +25,7 @@ func TestExecuteRootCmd(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// is this valid? dunno
|
||||
// is this valid? dunno...
|
||||
func TestExecuteFunc(t *testing.T) {
|
||||
Execute()
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// version holds app version string
|
||||
// version holds app version string.
|
||||
var version = "v0.0.13"
|
||||
|
||||
// used to determine whether to print short or long version string
|
||||
// used to determine whether to print short or long version string.
|
||||
var shortVersion = false
|
||||
|
||||
var cmdVersion = &cobra.Command{
|
||||
@ -30,7 +30,7 @@ var cmdVersion = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
// get (short if -s/--short flag is supplied) version
|
||||
// get (short if -s/--short flag is supplied) version.
|
||||
func getVersion() string {
|
||||
if !shortVersion {
|
||||
return appName + " - " + version
|
||||
@ -38,12 +38,12 @@ func getVersion() string {
|
||||
return GetShortVersion()
|
||||
}
|
||||
|
||||
// GetShortVersion returns a bare version string
|
||||
// GetShortVersion returns a bare version string.
|
||||
func GetShortVersion() string {
|
||||
return version
|
||||
}
|
||||
|
||||
// the init func registers the commands and flags with cobra
|
||||
// the init func registers the commands and flags with cobra.
|
||||
func init() {
|
||||
cmdVersion.Flags().BoolVarP(&shortVersion, "short", "s", false, "print just the version string and nothing else")
|
||||
Root.AddCommand(cmdVersion)
|
||||
|
@ -46,7 +46,7 @@ func TestGetVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// set shortVersion variable manually
|
||||
// set shortVersion variable manually.
|
||||
func TestGetVersionWithShortVersionVar(t *testing.T) {
|
||||
shortVersion = true
|
||||
want := version
|
||||
@ -58,7 +58,7 @@ func TestGetVersionWithShortVersionVar(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// explicitly get short version
|
||||
// explicitly get short version.
|
||||
func TestGetShortVersion(t *testing.T) {
|
||||
want := version
|
||||
got := GetShortVersion()
|
||||
|
@ -4,7 +4,7 @@
|
||||
package xkcdreader
|
||||
|
||||
import (
|
||||
// for embedding standard license header
|
||||
// for embedding standard license header.
|
||||
_ "embed"
|
||||
"log"
|
||||
|
||||
|
@ -23,7 +23,7 @@ const appGreeting = "welcome to go-xkcdreader"
|
||||
|
||||
var a fyne.App
|
||||
|
||||
// RunApp performs sets up and runs the main application
|
||||
// RunApp performs sets up and runs the main application.
|
||||
func RunApp() {
|
||||
// initialize the fyne application
|
||||
newApp()
|
||||
@ -61,7 +61,7 @@ func getApp() fyne.App {
|
||||
return a
|
||||
}
|
||||
|
||||
// makeGreeting creates a greeting label
|
||||
// makeGreeting creates a greeting label.
|
||||
func makeGreeting() *widget.Label {
|
||||
w := widget.NewLabel(appGreeting)
|
||||
w.TextStyle.Monospace = true
|
||||
@ -134,7 +134,7 @@ func makeBrowseUI() *fyne.Container {
|
||||
return browseUI
|
||||
}
|
||||
|
||||
// get img from filesystem, resize it and return as *canvas.Image
|
||||
// get img from filesystem, resize it and return as *canvas.Image.
|
||||
func getImg(imgPath string) *canvas.Image {
|
||||
_, err := os.Stat(imgPath)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user