Merge branch 'MageCleanup' of keybase://team/kbtui.dev.dxb/kbtui into dev
This commit is contained in:
44
mage.go
44
mage.go
@ -5,12 +5,13 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
)
|
||||
|
||||
// emoji related constants
|
||||
@ -61,8 +62,33 @@ func createEmojiSlice() ([]string, error) {
|
||||
return emojiSlice, nil
|
||||
}
|
||||
|
||||
func getRemotePackages() error {
|
||||
var packages = []string{
|
||||
"samhofi.us/x/keybase",
|
||||
"github.com/awesome-gocui/gocui",
|
||||
"github.com/magefile/mage/mage",
|
||||
"github.com/magefile/mage/mg",
|
||||
"github.com/magefile/mage/sh",
|
||||
}
|
||||
for _, p := range packages {
|
||||
if err := sh.Run("go", "get", "-u", p); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// proper error reporting and exit code
|
||||
func exit(err error) {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%+v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Build kbtui with emoji lookup support
|
||||
func BuildEmoji() error {
|
||||
mg.Deps(getRemotePackages)
|
||||
emojis, err := createEmojiSlice()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -82,16 +108,9 @@ func BuildEmoji() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// proper error reporting and exit code
|
||||
func exit(err error) {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%+v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Build kbtui with just the basic commands.
|
||||
func Build() {
|
||||
mg.Deps(getRemotePackages)
|
||||
if err := sh.Run("go", "build"); err != nil {
|
||||
defer func() {
|
||||
exit(err)
|
||||
@ -103,6 +122,7 @@ func Build() {
|
||||
// The ShowReactions TypeCommand will print a message in the feed window when
|
||||
// a reaction is received in the current conversation.
|
||||
func BuildShowReactions() {
|
||||
mg.Deps(getRemotePackages)
|
||||
if err := sh.Run("go", "build", "-tags", "showreactionscmd"); err != nil {
|
||||
defer func() {
|
||||
exit(err)
|
||||
@ -115,6 +135,7 @@ func BuildShowReactions() {
|
||||
// received in the current conversation. This gets pretty annoying, and
|
||||
// is not recommended.
|
||||
func BuildAutoReact() {
|
||||
mg.Deps(getRemotePackages)
|
||||
if err := sh.Run("go", "build", "-tags", "autoreactcmd"); err != nil {
|
||||
defer func() {
|
||||
exit(err)
|
||||
@ -124,6 +145,7 @@ func BuildAutoReact() {
|
||||
|
||||
// Build kbtui with all commands and TypeCommands disabled.
|
||||
func BuildAllCommands() {
|
||||
mg.Deps(getRemotePackages)
|
||||
if err := sh.Run("go", "build", "-tags", "allcommands"); err != nil {
|
||||
defer func() {
|
||||
exit(err)
|
||||
@ -133,6 +155,7 @@ func BuildAllCommands() {
|
||||
|
||||
// Build kbtui with all Commands and TypeCommands enabled.
|
||||
func BuildAllCommandsT() {
|
||||
mg.Deps(getRemotePackages)
|
||||
if err := sh.Run("go", "build", "-tags", "type_commands,allcommands"); err != nil {
|
||||
defer func() {
|
||||
exit(err)
|
||||
@ -142,6 +165,7 @@ func BuildAllCommandsT() {
|
||||
|
||||
// Build kbtui with beta functionality
|
||||
func BuildBeta() {
|
||||
mg.Deps(getRemotePackages)
|
||||
mg.Deps(BuildEmoji)
|
||||
if err := sh.Run("go", "build", "-tags", "allcommands,showreactionscmd,emojiList,tabcompletion"); err != nil {
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user