2021-10-21 00:51:32 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"ledo/app/cmd"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
version = "dev"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "ledo"
|
|
|
|
app.Usage = "LeadDocker helper for docker-compose work"
|
|
|
|
app.Description = appDescription
|
|
|
|
app.CustomAppHelpTemplate = helpTemplate
|
|
|
|
app.Version = version
|
|
|
|
app.Commands = []*cli.Command{
|
|
|
|
&cmd.CmdDocker,
|
|
|
|
&cmd.CmdMode,
|
2021-10-21 16:17:51 +00:00
|
|
|
&cmd.CmdAutocomplete,
|
2021-10-21 00:51:32 +00:00
|
|
|
}
|
|
|
|
app.EnableBashCompletion = true
|
|
|
|
err := app.Run(os.Args)
|
|
|
|
if err != nil {
|
|
|
|
// app.Run already exits for errors implementing ErrorCoder,
|
|
|
|
// so we only handle generic errors with code 1 here.
|
|
|
|
fmt.Fprintf(app.ErrWriter, "Error: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var appDescription = `LeadDocker (ledo) docker-compose project helper
|
|
|
|
`
|
|
|
|
|
|
|
|
var helpTemplate = bold(`
|
|
|
|
_ _ ___ _
|
|
|
|
| | ___ __ _ __| | \ ___ __| |_____ _ _
|
|
|
|
| |__/ -_) _' / _' | |) / _ \/ _| / / -_) '_|
|
|
|
|
|____\___\__,_\__,_|___/\___/\__|_\_\___|_| {{.Version}}
|
|
|
|
|
|
|
|
{{.Name}}{{if .Usage}} - {{.Usage}}{{end}}`) + `
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .Commands}} command [subcommand] [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
{{.Description | nindent 3 | trim}}{{end}}{{if .VisibleCommands}}
|
|
|
|
|
|
|
|
COMMANDS{{range .VisibleCategories}}{{if .Name}}
|
|
|
|
{{.Name}}:{{range .VisibleCommands}}
|
|
|
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
|
|
|
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
{{range $index, $option := .VisibleFlags}}{{if $index}}
|
|
|
|
{{end}}{{$option}}{{end}}{{end}}
|
|
|
|
|
|
|
|
EXAMPLES
|
|
|
|
ledo init # init ledo in project
|
|
|
|
ledo docker ps # print list of docker containers
|
|
|
|
|
|
|
|
|
|
|
|
ABOUT
|
|
|
|
Written & maintained by Aleksander "paramah" Cynarski
|
|
|
|
Thanks for StreamSage Team (https://streamsage.io)
|
|
|
|
|
|
|
|
More info about ledo on https://leaddocker.tech
|
|
|
|
`
|
|
|
|
|
|
|
|
func bold(t string) string {
|
|
|
|
return fmt.Sprintf("\033[1m%s\033[0m", t)
|
|
|
|
}
|