@@ -15,23 +15,27 @@ import (
1515"github.com/input-output-hk/catalyst-forge/lib/project/schema"
1616"github.com/input-output-hk/catalyst-forge/lib/project/secrets"
1717"github.com/input-output-hk/catalyst-forge/lib/tools/walker"
18+ "github.com/posener/complete"
19+ "github.com/willabides/kongplete"
1820)
1921
2022var version = "dev"
2123
2224var cli struct {
2325cmds.GlobalArgs
2426
25- Deploy cmds.DeployCmd `cmd:"" help:"Deploy a project."`
26- Dump cmds.DumpCmd `cmd:"" help:"Dumps a project's blueprint to JSON."`
27- CI cmds.CICmd `cmd:"" help:"Simulate a CI run."`
28- Release cmds.ReleaseCmd `cmd:"" help:"Release a project."`
29- Run cmds.RunCmd `cmd:"" help:"Run an Earthly target."`
30- Scan cmds.ScanCmd `cmd:"" help:"Scan for Earthfiles."`
31- Secret cmds.SecretCmd `cmd:"" help:"Manage secrets."`
32- Tag cmds.TagCmd `cmd:"" help:"Generate a tag for a project."`
33- Validate cmds.ValidateCmd `cmd:"" help:"Validates a project."`
34- Version VersionCmd `cmd:"" help:"Print the version."`
27+ Deploy cmds.DeployCmd `kong:"cmd" help:"Deploy a project."`
28+ Dump cmds.DumpCmd `kong:"cmd" help:"Dumps a project's blueprint to JSON."`
29+ CI cmds.CICmd `kong:"cmd" help:"Simulate a CI run."`
30+ Release cmds.ReleaseCmd `kong:"cmd" help:"Release a project."`
31+ Run cmds.RunCmd `kong:"cmd" help:"Run an Earthly target."`
32+ Scan cmds.ScanCmd `kong:"cmd" help:"Scan for Earthfiles."`
33+ Secret cmds.SecretCmd `kong:"cmd" help:"Manage secrets."`
34+ Tag cmds.TagCmd `kong:"cmd" help:"Generate a tag for a project."`
35+ Validate cmds.ValidateCmd `kong:"cmd" help:"Validates a project."`
36+ Version VersionCmd `kong:"cmd" help:"Print the version."`
37+
38+ InstallCompletions kongplete.InstallCompletions `cmd:"" help:"install shell completions"`
3539}
3640
3741type VersionCmd struct {}
@@ -50,10 +54,22 @@ func (c *VersionCmd) Run() error {
5054
5155// Run is the entrypoint for the CLI tool.
5256func Run () int {
53- ctx := kong .Parse (& cli ,
57+ cliArgs := os .Args [1 :]
58+
59+ parser := kong .Must (& cli ,
5460kong .Name ("forge" ),
5561kong .Description ("The CLI tool powering Catalyst Forge" ))
5662
63+ kongplete .Complete (parser ,
64+ kongplete .WithPredictor ("path" , complete .PredictFiles ("*" )),
65+ )
66+
67+ ctx , err := parser .Parse (cliArgs )
68+ if err != nil {
69+ fmt .Fprintf (os .Stderr , "forge: %v\n " , err )
70+ return 1
71+ }
72+
5773handler := log .New (os .Stderr )
5874switch cli .Verbose {
5975case 0 :
@@ -79,9 +95,8 @@ func Run() int {
7995}
8096ctx .Bind (runctx )
8197
82- err := ctx .Run ()
83- if err != nil {
84- fmt .Fprintf (os .Stderr , "forge: %v" , err )
98+ if err := ctx .Run (); err != nil {
99+ fmt .Fprintf (os .Stderr , "forge: %v\n " , err )
85100return 1
86101}
87102
0 commit comments