hoster/cmd/hoster_cli/hoster.go

64 lines
1.3 KiB
Go
Raw Normal View History

2024-09-11 11:41:04 +02:00
package hoster_cli
2024-08-28 12:31:17 +02:00
import (
"os"
"path/filepath"
2024-08-28 12:31:17 +02:00
"gitea.codeblob.work/pk/hoster/cmd/hoster_cli/commands"
"gitea.codeblob.work/pk/hoster/internals/conf"
2024-08-28 12:31:17 +02:00
"github.com/kataras/golog"
"github.com/urfave/cli/v2"
)
2024-09-11 11:41:04 +02:00
func Execute() {
homeDir, err := os.UserHomeDir()
if err != nil {
golog.Fatalf("Error getting home directory: %v", err)
}
conf.LoadConfig(filepath.Join(homeDir, ".hoster.yml"))
2024-08-28 12:31:17 +02:00
app := &cli.App{
2024-08-28 12:42:07 +02:00
Name: "hoster",
Usage: "Hoster",
2024-09-12 00:18:40 +02:00
Version: "1.0.4",
2024-08-28 12:31:17 +02:00
Commands: []*cli.Command{
{
Name: "new",
Usage: "Setup a new hosting project.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Usage: "The name of the project",
Required: true,
},
2024-09-12 00:18:40 +02:00
&cli.StringFlag{
Name: "custom-path",
Aliases: []string{"d"},
Usage: "The path of the project. Defaults to ${projects.root}/${name}.",
Required: false,
},
2024-08-28 12:31:17 +02:00
&cli.StringFlag{
Name: "domain",
Aliases: []string{"d"},
Usage: "The description of the project",
Required: true,
},
},
Action: commands.CmdNew,
},
{
Name: "check",
Usage: "Check if newer versions of docker images are available",
Action: commands.CmdCheckUpdated,
2024-08-28 12:31:17 +02:00
},
},
}
if err := app.Run(os.Args); err != nil {
golog.Fatal(err)
}
}