Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
361 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# tdl | ||
|
||
This is the `tdl` CLI tool used for running the interactive trainings on the [Three Dots Labs Academy](https://academy.threedots.tech). | ||
|
||
## Install | ||
|
||
### Script (macOS, Linux) | ||
|
||
```sh | ||
sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.sh)" -- -b /usr/local/bin``` | ||
``` | ||
### Script (Windows) | ||
Install to your home directory: | ||
```sh | ||
iwr https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.ps1 -useb | iex | ||
``` | ||
|
||
Or install in any chosen path: | ||
|
||
```sh | ||
$env:TDL_INSTALL = 'bin\' | ||
iwr https://raw.githubusercontent.com/ThreeDotsLabs/cli/master/install.ps1 -useb | iex | ||
``` | ||
|
||
### Binaries | ||
|
||
Download the latest binary from GitHub and move it to a directory in your `$PATH`. | ||
|
||
[See Releases](https://github.com/ThreeDotsLabs/cli/releases) | ||
|
||
### From source | ||
|
||
```sh | ||
go install github.com/ThreeDotsLabs/cli/tdl@latest | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package internal | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/fatih/color" | ||
"net/http" | ||
) | ||
|
||
type releaseResponse struct { | ||
TagName string `json:"tag_name"` | ||
} | ||
|
||
const repoURL = "https://github.com/ThreeDotsLabs/cli" | ||
const releasesURL = "https://api.github.com/repos/ThreeDotsLabs/cli/releases/latest" | ||
|
||
func CheckForUpdate(currentVersion string) { | ||
currentVersion = "v0.1.26" | ||
if currentVersion == "" || currentVersion == "dev" { | ||
return | ||
} | ||
|
||
resp, err := http.Get(releasesURL) | ||
if err != nil { | ||
return | ||
} | ||
defer func() { | ||
_ = resp.Body.Close() | ||
}() | ||
|
||
var release releaseResponse | ||
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil { | ||
return | ||
} | ||
|
||
if release.TagName != currentVersion { | ||
c := color.New(color.FgHiYellow) | ||
_, _ = c.Printf("A new version is available: %s (current: %s)\n", release.TagName, currentVersion) | ||
_, _ = c.Printf("Visit %v to update\n", repoURL) | ||
fmt.Println() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.