fix an example command and UpdateSelf()

This commit is contained in:
rhysd 2017-12-28 17:34:18 +09:00
parent 8618b269c4
commit 9c8dc3199b
2 changed files with 5 additions and 9 deletions

View File

@ -13,7 +13,7 @@ const version = "1.2.3"
func selfUpdate() error {
selfupdate.EnableLog()
previous := semver.Make(version)
previous := semver.MustParse(version)
latest, err := selfupdate.UpdateSelf(previous, "rhysd/go-github-selfupdate")
if err != nil {
return err
@ -22,14 +22,10 @@ func selfUpdate() error {
if previous.Equals(latest.Version) {
fmt.Println("Current binary is the latest version", version)
} else {
fmt.Printf(
`Update successfully done to version %v
Release note:
%s
`,
latest.Version, latest.Description)
fmt.Println("Update successfully done to version", latest.Version)
fmt.Println("Release note:\n", latest.Description)
}
return nil
}
func usage() {

View File

@ -111,5 +111,5 @@ func UpdateCommand(cmdPath string, current semver.Version, slug string) (*Releas
// UpdateSelf updates the running executable itself to the latest version.
// 'slug' represents 'owner/name' repository on GitHub and 'current' means the current version.
func UpdateSelf(current semver.Version, slug string) (*Release, error) {
return UpdateCommand(os.Args[0], current, slug, os.Args[0])
return UpdateCommand(os.Args[0], current, slug)
}