Files
dokku/plugins/repo/src/commands/commands.go
T
Jose Diaz-Gonzalez 45e3623ffd refactor: switch to go mod
This hopefully makes it a little easier to work with as the tooling is now based on something in golang core.

- move columnize usage to common plugin
- remove old vendor files
2020-06-28 01:11:28 -04:00

57 lines
1.2 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
)
const (
helpHeader = `Usage: dokku repo[:COMMAND]
Manage the app's repo
Additional commands:`
helpContent = `
repo:gc <app>, Runs 'git gc --aggressive' against the application's repo
repo:purge-cache <app>, Deletes the contents of the build cache stored in the repository
`
)
func main() {
flag.Usage = usage
flag.Parse()
cmd := flag.Arg(0)
switch cmd {
case "repo", "repo:help":
usage()
case "help":
command := common.NewShellCmd(fmt.Sprintf("ps -o command= %d", os.Getppid()))
command.ShowOutput = false
output, err := command.Output()
if err == nil && strings.Contains(string(output), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n repo, Manage the app's repo\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {
fmt.Println("failed to retrieve DOKKU_NOT_IMPLEMENTED_EXIT environment variable")
dokkuNotImplementExitCode = 10
}
os.Exit(dokkuNotImplementExitCode)
}
}
func usage() {
common.CommandUsage(helpHeader, helpContent)
}