Skip to content

Commit

Permalink
added bloop
Browse files Browse the repository at this point in the history
initial version with missing completions
  • Loading branch information
rsteube committed Nov 24, 2024
1 parent 031e694 commit a9fa8b7
Show file tree
Hide file tree
Showing 15 changed files with 388 additions and 0 deletions.
13 changes: 13 additions & 0 deletions completers/bloop_completer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine

RUN apk add --no-cache curl gcompat
RUN apk add --no-cache \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
elvish
RUN curl -fL "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz" \
| gzip -d > /usr/bin/cs \
&& chmod +x /usr/bin/cs
RUN cs install bloop --only-prebuilt=true

ENV PATH="$PATH:/root/.local/share/coursier/bin"
RUN bloop
17 changes: 17 additions & 0 deletions completers/bloop_completer/cmd/about.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var aboutCmd = &cobra.Command{
Use: "about",
Short: "show info",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(aboutCmd).Standalone()
rootCmd.AddCommand(aboutCmd)
}
27 changes: 27 additions & 0 deletions completers/bloop_completer/cmd/autocomplete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var autocompleteCmd = &cobra.Command{
Use: "autocomplete",
Short: "generate autocompletion",
Run: func(cmd *cobra.Command, args []string) {},
}

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

autocompleteCmd.Flags().String("command", "", "")
autocompleteCmd.Flags().String("format", "", "")
autocompleteCmd.Flags().String("mode", "", "")
autocompleteCmd.Flags().String("project", "", "")
rootCmd.AddCommand(autocompleteCmd)

// TODO flag completion
carapace.Gen(autocompleteCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("bash", "fish", "zsh"),
})
}
32 changes: 32 additions & 0 deletions completers/bloop_completer/cmd/bsp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd

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

var bspCmd = &cobra.Command{
Use: "bsp",
Short: "start build server",
Run: func(cmd *cobra.Command, args []string) {},
}

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

bspCmd.Flags().String("host", "", "the server host for the bsp server")
bspCmd.Flags().String("pipe-name", "", "a path to a new existing socket file to communicate through")
bspCmd.Flags().String("port", "", "the port for the bsp server")
bspCmd.Flags().String("protocol", "", "the connection protocol for the bsp server")
bspCmd.Flags().String("socket", "", "a path to a socket file to communicate through")
rootCmd.AddCommand(bspCmd)

carapace.Gen(bspCmd).FlagCompletion(carapace.ActionMap{
"host": net.ActionHosts(),
"pipe-name": carapace.ActionFiles(),
"port": net.ActionPorts(),
"protocol": carapace.ActionValues(), // TODO
"socket": carapace.ActionFiles(),
})
}
27 changes: 27 additions & 0 deletions completers/bloop_completer/cmd/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var cleanCmd = &cobra.Command{
Use: "clean",
Short: "clean compilation caches",
Run: func(cmd *cobra.Command, args []string) {},
}

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

cleanCmd.Flags().Bool("cascade", false, "clean a project and all projects depending on it")
cleanCmd.Flags().Bool("include-dependencies", false, "clean a project and all its dependencies")
cleanCmd.Flags().StringSliceP("project", "p", nil, "the projects to clean")
cleanCmd.Flags().StringSlice("projects", nil, "the projects to clean")
cleanCmd.Flags().Bool("propagate", false, "clean a project and all its dependencies")
rootCmd.AddCommand(cleanCmd)

cleanCmd.MarkFlagsMutuallyExclusive("include-dependencies", "propagate")

// TODO completion
}
27 changes: 27 additions & 0 deletions completers/bloop_completer/cmd/compile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var compileCmd = &cobra.Command{
Use: "compile",
Short: "compile projects",
Run: func(cmd *cobra.Command, args []string) {},
}

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

compileCmd.Flags().Bool("cascade", false, "compile a project and all projects depending on it")
compileCmd.Flags().Bool("incremental", false, "compile the project incrementally")
compileCmd.Flags().Bool("pipeline", false, "pipeline the compilation of modules in your build")
compileCmd.Flags().StringSliceP("project", "p", nil, "the projects to compile")
compileCmd.Flags().StringSlice("projects", nil, "the projects to compile")
compileCmd.Flags().String("reporter", "", "pick reporter to show compilation messages")
compileCmd.Flags().BoolP("watch", "w", false, "run the command when projects' source files change")
rootCmd.AddCommand(compileCmd)

// TODO completion
}
19 changes: 19 additions & 0 deletions completers/bloop_completer/cmd/configure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var configureCmd = &cobra.Command{
Use: "configure",
Short: "configure projecs",
Run: func(cmd *cobra.Command, args []string) {},
}

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

configureCmd.Flags().String("threads", "", "set the number of threads used to compile and test all projects")
rootCmd.AddCommand(configureCmd)
}
39 changes: 39 additions & 0 deletions completers/bloop_completer/cmd/console.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var consoleCmd = &cobra.Command{
Use: "console",
Short: "start console",
Run: func(cmd *cobra.Command, args []string) {},
}

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

consoleCmd.Flags().String("ammonite-version", "", "the Ammonite version to use")
consoleCmd.Flags().StringSlice("args", nil, "the arguments to pass in to Ammonite")
consoleCmd.Flags().Bool("exclude-root", false, "start up the console compiling only the target project's dependencies")
consoleCmd.Flags().Bool("incremental", false, "compile the project incrementally")
consoleCmd.Flags().String("out-file", "", "the output file where the Ammonite command is written")
consoleCmd.Flags().Bool("pipeline", false, "pipeline the compilation of modules in your build")
consoleCmd.Flags().StringSliceP("project", "p", nil, "the projects to run the console at")
consoleCmd.Flags().StringSlice("projects", nil, "the projects to run the console at")
consoleCmd.Flags().String("repl", "", "pick REPL to run console")
consoleCmd.Flags().String("reporter", "", "pick reporter to show compilation messages")
rootCmd.AddCommand(consoleCmd)

// TODO completion
carapace.Gen(consoleCmd).FlagCompletion(carapace.ActionMap{
"ammonite-version": carapace.ActionValues(),
"args": carapace.ActionValues(),
"out-file": carapace.ActionFiles(),
"project": carapace.ActionValues(),
"projects": carapace.ActionValues(),
"repl": carapace.ActionValues("scalac", "ammonite"),
"reporter": carapace.ActionValues(),
})
}
18 changes: 18 additions & 0 deletions completers/bloop_completer/cmd/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

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

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

rootCmd.AddCommand(helpCmd)
}
34 changes: 34 additions & 0 deletions completers/bloop_completer/cmd/link.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var linkCmd = &cobra.Command{
Use: "link",
Short: "link projects",
Run: func(cmd *cobra.Command, args []string) {},
}

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

linkCmd.Flags().Bool("incremental", false, "compile the project incrementally")
linkCmd.Flags().StringP("main", "m", "", "the main class to link")
linkCmd.Flags().StringP("optimize", "O", "", "optimization level of the linker")
linkCmd.Flags().Bool("pipeline", false, "pipeline the compilation of modules in your build")
linkCmd.Flags().StringSliceP("project", "p", nil, "the projects to link")
linkCmd.Flags().StringSlice("projects", nil, "the projects to link")
linkCmd.Flags().Bool("reporter", false, "pick reporter to show compilation messages")
linkCmd.Flags().BoolP("watch", "w", false, "run the command whenever projects' source files change")
rootCmd.AddCommand(linkCmd)

// TODO completion
carapace.Gen(linkCmd).FlagCompletion(carapace.ActionMap{
"main": carapace.ActionValues(),
"optimize": carapace.ActionValues("debug", "release"),
"project": carapace.ActionValues(),
"projects": carapace.ActionValues(),
})
}
19 changes: 19 additions & 0 deletions completers/bloop_completer/cmd/projects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var projectsCmd = &cobra.Command{
Use: "projects",
Short: "list projects",
Run: func(cmd *cobra.Command, args []string) {},
}

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

projectsCmd.Flags().Bool("dot-graph", false, "print out a dot graph you can pipe into `dot`")
rootCmd.AddCommand(projectsCmd)
}
32 changes: 32 additions & 0 deletions completers/bloop_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "bloop",
Short: "Build and test Scala code",
Long: "https://scalacenter.github.io/bloop/",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.PersistentFlags().StringP("config-dir", "c", "", "file path to the bloop config directory")
rootCmd.PersistentFlags().String("debug", "", "Debug the execution of a concrete task")
rootCmd.PersistentFlags().Bool("no-color", false, "do not color output")
rootCmd.PersistentFlags().Bool("verbose", false, "print out debugging information to stderr")
rootCmd.PersistentFlags().BoolP("version", "v", false, "print the root section at the beginning of the execution")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"config-dir": carapace.ActionDirectories(),
"debug": carapace.ActionValues("all", "file-watching", "compilation", "test", "bsp", "link"), // TODO list?
})

}
38 changes: 38 additions & 0 deletions completers/bloop_completer/cmd/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var runCmd = &cobra.Command{
Use: "run",
Short: "run a project",
Run: func(cmd *cobra.Command, args []string) {},
}

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

runCmd.Flags().StringSlice("args", nil, "the arguments to pass in to the main class")
runCmd.Flags().Bool("incremental", false, "compile the project incrementally")
runCmd.Flags().StringP("main", "m", "", "the main class to run")
runCmd.Flags().StringP("optimize", "O", "", "if an optimizer is used, run it in `debug` or `release` mode")
runCmd.Flags().Bool("pipeline", false, "pipeline the compilation of modules in your build")
runCmd.Flags().StringSliceP("project", "p", nil, "the projects to run")
runCmd.Flags().StringSlice("projects", nil, "the projects to run")
runCmd.Flags().String("reporter", "", "pick reporter to show compilation messages")
runCmd.Flags().Bool("skip-jargs", false, "ignore arguments starting with `-J` and forward them instead")
runCmd.Flags().BoolP("watch", "w", false, "run the command whenever projects' source files change")
rootCmd.AddCommand(runCmd)

// TODO completion
carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{
"args": carapace.ActionValues(),
"main": carapace.ActionValues(),
"optimize": carapace.ActionValues("debug", "release"),
"project": carapace.ActionValues(),
"projects": carapace.ActionValues(),
"reporter": carapace.ActionValues(),
})
}
39 changes: 39 additions & 0 deletions completers/bloop_completer/cmd/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var testCmd = &cobra.Command{
Use: "test",
Short: "run tests",
Run: func(cmd *cobra.Command, args []string) {},
}

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

testCmd.Flags().StringSlice("args", nil, "the arguments to pass in to the test framework")
testCmd.Flags().Bool("cascade", false, "test a project and all projects depending on it")
testCmd.Flags().Bool("include-dependencies", false, "test a project and all its dependencies")
testCmd.Flags().Bool("incremental", false, "compile the project incrementally")
testCmd.Flags().StringP("only", "o", "", "the list of test suite filters to test for only")
testCmd.Flags().Bool("parallel", false, "run tests in parallel")
testCmd.Flags().Bool("pipeline", false, "pipeline the compilation of modules in your build")
testCmd.Flags().StringSliceP("project", "p", nil, "the projects to test")
testCmd.Flags().StringSlice("projects", nil, "the projects to test")
testCmd.Flags().Bool("propagate", false, "test a project and all its dependencies")
testCmd.Flags().String("reporter", "", "pick reporter to show compilation messages")
testCmd.Flags().BoolP("watch", "w", false, "run the command when projects' source files change")
rootCmd.AddCommand(testCmd)

// TODO completion
carapace.Gen(testCmd).FlagCompletion(carapace.ActionMap{
"args": carapace.ActionValues(),
"only": carapace.ActionValues(),
"project": carapace.ActionValues(),
"projects": carapace.ActionValues(),
"reporter": carapace.ActionValues(),
})
}
Loading

0 comments on commit a9fa8b7

Please sign in to comment.