File tree Expand file tree Collapse file tree 2 files changed +0
-171
lines changed
Expand file tree Collapse file tree 2 files changed +0
-171
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,31 +2,13 @@ package utils
22
33import (
44 "errors"
5- "fmt"
65 "os"
76 "os/exec"
8- "path/filepath"
97 "runtime"
10- "strings"
11- "time"
128
13- "github.com/github/gh-cli/ui"
149 "github.com/kballard/go-shellquote"
1510)
1611
17- var timeNow = time .Now
18-
19- func Check (err error ) {
20- if err != nil {
21- ui .Errorln (err )
22- os .Exit (1 )
23- }
24- }
25-
26- func ConcatPaths (paths ... string ) string {
27- return strings .Join (paths , "/" )
28- }
29-
3012func OpenInBrowser (url string ) error {
3113 browser := os .Getenv ("BROWSER" )
3214 if browser == "" {
@@ -69,58 +51,3 @@ func searchBrowserLauncher(goos string) (browser string) {
6951
7052 return browser
7153}
72-
73- func CommandPath (cmd string ) (string , error ) {
74- if runtime .GOOS == "windows" {
75- cmd = cmd + ".exe"
76- }
77-
78- path , err := exec .LookPath (cmd )
79- if err != nil {
80- return "" , err
81- }
82-
83- path , err = filepath .Abs (path )
84- if err != nil {
85- return "" , err
86- }
87-
88- return filepath .EvalSymlinks (path )
89- }
90-
91- func TimeAgo (t time.Time ) string {
92- duration := timeNow ().Sub (t )
93- minutes := duration .Minutes ()
94- hours := duration .Hours ()
95- days := hours / 24
96- months := days / 30
97- years := months / 12
98-
99- var val int
100- var unit string
101-
102- if minutes < 1 {
103- return "now"
104- } else if hours < 1 {
105- val = int (minutes )
106- unit = "minute"
107- } else if days < 1 {
108- val = int (hours )
109- unit = "hour"
110- } else if months < 1 {
111- val = int (days )
112- unit = "day"
113- } else if years < 1 {
114- val = int (months )
115- unit = "month"
116- } else {
117- val = int (years )
118- unit = "year"
119- }
120-
121- var plural string
122- if val > 1 {
123- plural = "s"
124- }
125- return fmt .Sprintf ("%d %s%s ago" , val , unit , plural )
126- }
You can’t perform that action at this time.
0 commit comments