Skip to content

Commit

Permalink
added dagger
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 14, 2024
1 parent 0e5ddb7 commit 531b1b4
Show file tree
Hide file tree
Showing 28 changed files with 1,314 additions and 0 deletions.
33 changes: 33 additions & 0 deletions completers/dagger_completer/cmd/call.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/spf13/cobra"
)

var callCmd = &cobra.Command{
Use: "call [flags] [FUNCTION]...",
Short: "Call a module function",
GroupID: "module",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(callCmd).Standalone()

callCmd.PersistentFlags().Bool("focus", false, "Only show output for focused commands")
callCmd.PersistentFlags().Bool("json", false, "Present result as JSON")
callCmd.PersistentFlags().StringP("mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")")
callCmd.PersistentFlags().StringP("output", "o", "", "Path in the host to save the result to")
rootCmd.AddCommand(callCmd)

carapace.Gen(callCmd).FlagCompletion(carapace.ActionMap{
"mod": dagger.ActionMods(),
"output": carapace.ActionFiles(),
})

carapace.Gen(callCmd).PositionalAnyCompletion(
dagger.ActionFunctions(),
)
}
18 changes: 18 additions & 0 deletions completers/dagger_completer/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate the autocompletion script for the specified shell",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completionCmd).Standalone()

rootCmd.AddCommand(completionCmd)
}
19 changes: 19 additions & 0 deletions completers/dagger_completer/cmd/completion_bash.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_bashCmd = &cobra.Command{
Use: "bash",
Short: "Generate the autocompletion script for bash",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_bashCmd).Standalone()

completion_bashCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_bashCmd)
}
19 changes: 19 additions & 0 deletions completers/dagger_completer/cmd/completion_fish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_fishCmd = &cobra.Command{
Use: "fish",
Short: "Generate the autocompletion script for fish",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_fishCmd).Standalone()

completion_fishCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_fishCmd)
}
19 changes: 19 additions & 0 deletions completers/dagger_completer/cmd/completion_powershell.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_powershellCmd = &cobra.Command{
Use: "powershell",
Short: "Generate the autocompletion script for powershell",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_powershellCmd).Standalone()

completion_powershellCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_powershellCmd)
}
19 changes: 19 additions & 0 deletions completers/dagger_completer/cmd/completion_zsh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_zshCmd = &cobra.Command{
Use: "zsh",
Short: "Generate the autocompletion script for zsh",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_zshCmd).Standalone()

completion_zshCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_zshCmd)
}
30 changes: 30 additions & 0 deletions completers/dagger_completer/cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/spf13/cobra"
)

var configCmd = &cobra.Command{
Use: "config",
Short: "Get or set the configuration of a Dagger module",
GroupID: "module",
Aliases: []string{"mod"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(configCmd).Standalone()
configCmd.AddGroup(
&cobra.Group{ID: "module", Title: ""},
)

configCmd.PersistentFlags().Bool("focus", false, "Only show output for focused commands")
configCmd.PersistentFlags().StringP("mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")")
rootCmd.AddCommand(configCmd)

carapace.Gen(configCmd).FlagCompletion(carapace.ActionMap{
"mod": dagger.ActionMods(),
})
}
30 changes: 30 additions & 0 deletions completers/dagger_completer/cmd/develop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/spf13/cobra"
)

var developCmd = &cobra.Command{
Use: "develop",
Short: "Setup or update all the resources needed to develop on a module locally",
GroupID: "module",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(developCmd).Standalone()

developCmd.PersistentFlags().Bool("focus", false, "Only show output for focused commands")
developCmd.PersistentFlags().StringP("mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")")
developCmd.Flags().String("sdk", "", "New SDK for the module")
developCmd.Flags().String("source", "", "Directory to store the module implementation source code in")
rootCmd.AddCommand(developCmd)

carapace.Gen(developCmd).FlagCompletion(carapace.ActionMap{
"mod": dagger.ActionMods(),
"sdk": dagger.ActionSdks(),
"source": carapace.ActionDirectories(),
})
}
30 changes: 30 additions & 0 deletions completers/dagger_completer/cmd/functions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/spf13/cobra"
)

var functionsCmd = &cobra.Command{
Use: "functions [flags] [FUNCTION]...",
Short: "List available functions",
GroupID: "module",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(functionsCmd).Standalone()

functionsCmd.PersistentFlags().Bool("focus", false, "Only show output for focused commands")
functionsCmd.PersistentFlags().StringP("mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")")
rootCmd.AddCommand(functionsCmd)

carapace.Gen(functionsCmd).FlagCompletion(carapace.ActionMap{
"mod": dagger.ActionMods(),
})

carapace.Gen(functionsCmd).PositionalAnyCompletion(
dagger.ActionFunctions().FilterArgs(),
)
}
30 changes: 30 additions & 0 deletions completers/dagger_completer/cmd/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var genCmd = &cobra.Command{
Use: "gen FILE",
Short: "Generate CLI reference documentation",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(genCmd).Standalone()

genCmd.Flags().String("frontmatter", "", "Prepend content to beginning of generated file")
genCmd.Flags().Bool("include-experimental", false, "Show experimental commands in the generated documentation")
genCmd.Flags().StringP("output", "o", "", "Save to file")
rootCmd.AddCommand(genCmd)

carapace.Gen(genCmd).FlagCompletion(carapace.ActionMap{
"output": carapace.ActionFiles(),
})

carapace.Gen(genCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}
22 changes: 22 additions & 0 deletions completers/dagger_completer/cmd/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var helpCmd = &cobra.Command{
Use: "help [command]",
Short: "Help about any command",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(helpCmd).Standalone()

rootCmd.AddCommand(helpCmd)

carapace.Gen(helpCmd).PositionalAnyCompletion(
carapace.ActionCommands(rootCmd),
)
}
34 changes: 34 additions & 0 deletions completers/dagger_completer/cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/spf13/cobra"
)

var initCmd = &cobra.Command{
Use: "init [flags] [PATH]",
Short: "Initialize a new Dagger module",
GroupID: "module",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(initCmd).Standalone()

initCmd.Flags().String("license", "", "License identifier to generate - see https://spdx.org/licenses/")
initCmd.Flags().String("name", "", "Name of the new module (defaults to parent directory name)")
initCmd.Flags().String("sdk", "", "Optionally initialize module for development in the given SDK")
initCmd.Flags().String("source", "", "Directory to store the module implementation source code in (defaults to \"dagger/ if \"--sdk\" is provided)")
rootCmd.AddCommand(initCmd)

carapace.Gen(initCmd).FlagCompletion(carapace.ActionMap{
"license": dagger.ActionLicenses(),
"sdk": dagger.ActionSdks(),
"source": carapace.ActionDirectories(),
})

carapace.Gen(initCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
40 changes: 40 additions & 0 deletions completers/dagger_completer/cmd/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/rsteube/carapace-bin/pkg/actions/tools/git"
"github.com/spf13/cobra"
)

var installCmd = &cobra.Command{
Use: "install [flags] MODULE",
Short: "Add a new dependency to a Dagger module",
GroupID: "module",
Aliases: []string{"use"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(installCmd).Standalone()

installCmd.Flags().Bool("focus", false, "Only show output for focused commands")
installCmd.Flags().StringP("mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")")
installCmd.Flags().StringP("name", "n", "", "Name to use for the dependency in the module. Defaults to the name of the module being installed.")
rootCmd.AddCommand(installCmd)

carapace.Gen(installCmd).FlagCompletion(carapace.ActionMap{
"mod": dagger.ActionMods(),
})

carapace.Gen(installCmd).PositionalCompletion(
carapace.ActionMultiPartsN("@", 2, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return git.ActionRepositorySearch(git.SearchOpts{Github: true})
default:
return git.ActionLsRemoteRefs(git.LsRemoteRefOption{Url: "https://" + c.Parts[0], Branches: true, Tags: true})
}
}),
)
}
39 changes: 39 additions & 0 deletions completers/dagger_completer/cmd/listen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/net"
"github.com/rsteube/carapace-bin/pkg/actions/tools/dagger"
"github.com/spf13/cobra"
)

var listenCmd = &cobra.Command{
Use: "listen",
Short: "Starts the engine server",
Aliases: []string{"l"},
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(listenCmd).Standalone()

listenCmd.Flags().Bool("allow-cors", false, "allow Cross-Origin Resource Sharing (CORS) requests")
listenCmd.Flags().Bool("disable-host-read-write", false, "disable host read/write access")
listenCmd.PersistentFlags().Bool("focus", false, "Only show output for focused commands")
listenCmd.Flags().String("listen", "", "Listen on network address ADDR")
listenCmd.PersistentFlags().StringP("mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")")
rootCmd.AddCommand(listenCmd)

carapace.Gen(listenCmd).FlagCompletion(carapace.ActionMap{
"listen": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return carapace.ActionValues()
default:
return net.ActionPorts()
}
}),
"mod": dagger.ActionMods(),
})
}
Loading

0 comments on commit 531b1b4

Please sign in to comment.