Skip to content

Commit

Permalink
devbox: updates from 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 6, 2022
1 parent 71c8dc0 commit 4a5c66d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
12 changes: 11 additions & 1 deletion completers/devbox_completer/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

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

Expand All @@ -13,7 +14,16 @@ var addCmd = &cobra.Command{

func init() {
carapace.Gen(addCmd).Standalone()
addCmd.Flags().StringP("config", "c", "", "path to directory containing a devbox.json config file")
rootCmd.AddCommand(addCmd)

// TODO nix package search
carapace.Gen(addCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionDirectories(),
})

carapace.Gen(addCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return nix.ActionChannelPackages().Invoke(c).Filter(c.Parts).ToA()
}),
)
}
2 changes: 2 additions & 0 deletions completers/devbox_completer/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ var buildCmd = &cobra.Command{

func init() {
carapace.Gen(buildCmd).Standalone()
buildCmd.Flags().StringP("config", "c", "", "path to directory containing a devbox.json config file")
buildCmd.Flags().String("engine", "docker", "Engine used to build the container: 'docker', 'podman'")
buildCmd.Flags().String("name", "devbox", "name for the container")
buildCmd.Flags().Bool("no-cache", false, "Do not use a cache")
buildCmd.Flags().StringSlice("tags", []string{}, "tags for the container")
rootCmd.AddCommand(buildCmd)

carapace.Gen(buildCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionDirectories(),
"engine": carapace.ActionValues("docker", "podman"),
})

Expand Down
5 changes: 5 additions & 0 deletions completers/devbox_completer/cmd/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ var planCmd = &cobra.Command{

func init() {
carapace.Gen(planCmd).Standalone()
planCmd.Flags().StringP("config", "c", "", "path to directory containing a devbox.json config file")
rootCmd.AddCommand(planCmd)

carapace.Gen(planCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionDirectories(),
})

carapace.Gen(planCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
Expand Down
5 changes: 5 additions & 0 deletions completers/devbox_completer/cmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ var rmCmd = &cobra.Command{

func init() {
carapace.Gen(rmCmd).Standalone()
rmCmd.Flags().StringP("config", "c", "", "path to directory containing a devbox.json config file")
rootCmd.AddCommand(rmCmd)

carapace.Gen(rmCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionDirectories(),
})

carapace.Gen(rmCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return devbox.ActionInstalledPackages().Invoke(c).Filter(c.Args).ToA()
Expand Down
6 changes: 6 additions & 0 deletions completers/devbox_completer/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ var shellCmd = &cobra.Command{

func init() {
carapace.Gen(shellCmd).Standalone()
shellCmd.Flags().StringP("config", "c", "", "path to directory containing a devbox.json config file")
shellCmd.Flags().Bool("print-env", false, "Print script to setup shell environment")
rootCmd.AddCommand(shellCmd)

carapace.Gen(shellCmd).FlagCompletion(carapace.ActionMap{
"config": carapace.ActionDirectories(),
})

carapace.Gen(shellCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
Expand Down

0 comments on commit 4a5c66d

Please sign in to comment.