2018-10-16 16:20:25 +00:00
|
|
|
// doodad is the command line developer tool for Doodle.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-04-10 02:17:56 +00:00
|
|
|
"fmt"
|
2018-10-16 16:20:25 +00:00
|
|
|
"os"
|
|
|
|
"sort"
|
2019-04-10 02:17:56 +00:00
|
|
|
"time"
|
2018-10-16 16:20:25 +00:00
|
|
|
|
|
|
|
"git.kirsle.net/apps/doodle/cmd/doodad/commands"
|
2019-06-24 00:52:48 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/branding"
|
2021-06-17 04:55:45 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/license"
|
2021-06-20 05:14:41 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/log"
|
2020-11-15 23:20:15 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2018-10-16 16:20:25 +00:00
|
|
|
)
|
|
|
|
|
2019-04-10 02:17:56 +00:00
|
|
|
// Build variables.
|
|
|
|
var (
|
|
|
|
Build = "N/A"
|
|
|
|
BuildDate string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if BuildDate == "" {
|
|
|
|
BuildDate = time.Now().Format(time.RFC3339)
|
|
|
|
}
|
|
|
|
}
|
2018-10-16 16:20:25 +00:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "doodad"
|
|
|
|
app.Usage = "command line interface for Doodle"
|
2019-04-20 00:23:37 +00:00
|
|
|
|
|
|
|
var freeLabel string
|
2021-06-17 04:55:45 +00:00
|
|
|
if !license.IsRegistered() {
|
2019-04-20 00:23:37 +00:00
|
|
|
freeLabel = " (shareware)"
|
|
|
|
}
|
|
|
|
|
|
|
|
app.Version = fmt.Sprintf("%s build %s%s. Built on %s",
|
2019-06-24 00:52:48 +00:00
|
|
|
branding.Version,
|
2019-04-10 02:17:56 +00:00
|
|
|
Build,
|
2019-04-20 00:23:37 +00:00
|
|
|
freeLabel,
|
2019-04-10 02:17:56 +00:00
|
|
|
BuildDate,
|
|
|
|
)
|
2018-10-16 16:20:25 +00:00
|
|
|
|
|
|
|
app.Flags = []cli.Flag{
|
2020-06-05 06:11:03 +00:00
|
|
|
&cli.BoolFlag{
|
2018-10-16 16:20:25 +00:00
|
|
|
Name: "debug, d",
|
|
|
|
Usage: "enable debug level logging",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-06-05 06:11:03 +00:00
|
|
|
app.Commands = []*cli.Command{
|
2018-10-16 16:20:25 +00:00
|
|
|
commands.Convert,
|
2019-07-07 06:28:11 +00:00
|
|
|
commands.Show,
|
|
|
|
commands.EditLevel,
|
|
|
|
commands.EditDoodad,
|
2019-04-16 06:07:15 +00:00
|
|
|
commands.InstallScript,
|
2021-12-24 03:15:32 +00:00
|
|
|
commands.LevelPack,
|
2018-10-16 16:20:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sort.Sort(cli.FlagsByName(app.Flags))
|
|
|
|
sort.Sort(cli.CommandsByName(app.Commands))
|
|
|
|
|
|
|
|
err := app.Run(os.Args)
|
|
|
|
if err != nil {
|
2021-06-20 05:14:41 +00:00
|
|
|
log.Error("Fatal: %s", err)
|
|
|
|
os.Exit(1)
|
2018-10-16 16:20:25 +00:00
|
|
|
}
|
|
|
|
}
|