Skip to content

Commit

Permalink
🔥 unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Nov 26, 2019
1 parent a5da699 commit 7f4833d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 171 deletions.
98 changes: 0 additions & 98 deletions ui/ui.go

This file was deleted.

73 changes: 0 additions & 73 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,13 @@ package utils

import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/github/gh-cli/ui"
"github.com/kballard/go-shellquote"
)

var timeNow = time.Now

func Check(err error) {
if err != nil {
ui.Errorln(err)
os.Exit(1)
}
}

func ConcatPaths(paths ...string) string {
return strings.Join(paths, "/")
}

func OpenInBrowser(url string) error {
browser := os.Getenv("BROWSER")
if browser == "" {
Expand Down Expand Up @@ -69,58 +51,3 @@ func searchBrowserLauncher(goos string) (browser string) {

return browser
}

func CommandPath(cmd string) (string, error) {
if runtime.GOOS == "windows" {
cmd = cmd + ".exe"
}

path, err := exec.LookPath(cmd)
if err != nil {
return "", err
}

path, err = filepath.Abs(path)
if err != nil {
return "", err
}

return filepath.EvalSymlinks(path)
}

func TimeAgo(t time.Time) string {
duration := timeNow().Sub(t)
minutes := duration.Minutes()
hours := duration.Hours()
days := hours / 24
months := days / 30
years := months / 12

var val int
var unit string

if minutes < 1 {
return "now"
} else if hours < 1 {
val = int(minutes)
unit = "minute"
} else if days < 1 {
val = int(hours)
unit = "hour"
} else if months < 1 {
val = int(days)
unit = "day"
} else if years < 1 {
val = int(months)
unit = "month"
} else {
val = int(years)
unit = "year"
}

var plural string
if val > 1 {
plural = "s"
}
return fmt.Sprintf("%d %s%s ago", val, unit, plural)
}

0 comments on commit 7f4833d

Please sign in to comment.