-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1910 from rsteube/add-templ
added templ
- Loading branch information
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var fmtCmd = &cobra.Command{ | ||
Use: "fmt", | ||
Short: "Format *.templ files", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(fmtCmd).Standalone() | ||
|
||
fmtCmd.Flags().BoolS("help", "help", false, "Print help and exit.") | ||
rootCmd.AddCommand(fmtCmd) | ||
|
||
carapace.Gen(fmtCmd).PositionalCompletion( | ||
carapace.ActionDirectories(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/net" | ||
"github.com/rsteube/carapace-bridge/pkg/actions/bridge" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var generateCmd = &cobra.Command{ | ||
Use: "generate", | ||
Short: "Generate Go code from *.templ files", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(generateCmd).Standalone() | ||
|
||
generateCmd.Flags().StringS("cmd", "cmd", "", "Set the command to run after generating code") | ||
generateCmd.Flags().StringS("f", "f", "", "Optionally generates code for a single file") | ||
generateCmd.Flags().BoolS("help", "help", false, "Print help and exit.") | ||
generateCmd.Flags().StringS("path", "path", "", "Generates code for all files in path") | ||
generateCmd.Flags().StringS("pprof", "pprof", "", "Port to start pprof web server on") | ||
generateCmd.Flags().StringS("proxy", "proxy", "", "Set the URL to proxy") | ||
generateCmd.Flags().StringS("proxyport", "proxyport", "", "The port the proxy will listen on") | ||
generateCmd.Flags().BoolS("sourceMapVisualisations", "sourceMapVisualisations", false, "Generate HTML files to visualise the templ code") | ||
generateCmd.Flags().StringS("w", "w", "", "Number of workers to run in parallel") | ||
generateCmd.Flags().BoolS("watch", "watch", false, "Watch the path for changes and regenerate code") | ||
rootCmd.AddCommand(generateCmd) | ||
|
||
carapace.Gen(generateCmd).FlagCompletion(carapace.ActionMap{ | ||
"cmd": bridge.ActionCarapaceBin().Split(), | ||
"f": carapace.ActionFiles(), | ||
"path": carapace.ActionDirectories(), | ||
"pprof": net.ActionPorts(), | ||
"proxyport": net.ActionPorts(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/net" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var lspCmd = &cobra.Command{ | ||
Use: "lsp", | ||
Short: "Start LSP server", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(lspCmd).Standalone() | ||
|
||
lspCmd.Flags().StringS("goplsLog", "goplsLog", "", "The file to log gopls output, or leave empty to disable logging.") | ||
lspCmd.Flags().BoolS("goplsRPCTrace", "goplsRPCTrace", false, "Set gopls to log input and output messages") | ||
lspCmd.Flags().BoolS("help", "help", false, "Print help and exit") | ||
lspCmd.Flags().StringS("http", "http", "", "Enable http debug server by setting a listen address") | ||
lspCmd.Flags().StringS("log", "log", "", "The file to log templ LSP output to, or leave empty to disable logging") | ||
lspCmd.Flags().BoolS("pprof", "pprof", false, "Enable pprof web server") | ||
rootCmd.AddCommand(lspCmd) | ||
|
||
carapace.Gen(lspCmd).FlagCompletion(carapace.ActionMap{ | ||
"goplsLog": carapace.ActionFiles(), | ||
"http": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { | ||
switch len(c.Parts) { | ||
case 0: | ||
return carapace.ActionValues() | ||
default: | ||
return net.ActionPorts() | ||
} | ||
}), | ||
"log": carapace.ActionFiles(), | ||
"pprof": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { | ||
switch len(c.Parts) { | ||
case 0: | ||
return carapace.ActionValues() | ||
default: | ||
return net.ActionPorts() | ||
} | ||
}), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var migrateCmd = &cobra.Command{ | ||
Use: "migrate", | ||
Short: "Migrate *.templ files", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(migrateCmd).Standalone() | ||
|
||
migrateCmd.Flags().StringS("f", "f", "", "Optionally migrate a single file") | ||
migrateCmd.Flags().BoolS("help", "help", false, "Print help and exit") | ||
migrateCmd.Flags().StringS("path", "path", "", "Migrates code for all files in path") | ||
rootCmd.AddCommand(migrateCmd) | ||
|
||
carapace.Gen(migrateCmd).FlagCompletion(carapace.ActionMap{ | ||
"f": carapace.ActionFiles(".templ"), | ||
"path": carapace.ActionDirectories(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "templ", | ||
Short: "A language for writing HTML user interfaces in Go", | ||
Long: "https://github.com/a-h/templ", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/rsteube/carapace-bin/completers/templ_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |