Skip to content

Commit 7925856

Browse files
authored
[path] Add global path command (#1077)
## Summary Inspired by #1058 ## How was it tested? ```bash ➜ devbox git:(landau/global-path) devbox global path /Users/mike/.local/share/devbox/global/default ```
1 parent 59a29ae commit 7925856

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

internal/boxcli/global.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func globalCmd() *cobra.Command {
2525

2626
addCommandAndHideConfigFlag(globalCmd, addCmd())
2727
addCommandAndHideConfigFlag(globalCmd, installCmd())
28+
addCommandAndHideConfigFlag(globalCmd, pathCmd())
2829
addCommandAndHideConfigFlag(globalCmd, pullCmd())
2930
addCommandAndHideConfigFlag(globalCmd, removeCmd())
3031
addCommandAndHideConfigFlag(globalCmd, runCmd())

internal/boxcli/path.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2023 Jetpack Technologies Inc and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
package boxcli
5+
6+
import (
7+
"fmt"
8+
9+
"github.com/spf13/cobra"
10+
)
11+
12+
type pathCmdFlags struct {
13+
config configFlags
14+
}
15+
16+
func pathCmd() *cobra.Command {
17+
flags := pathCmdFlags{}
18+
cmd := &cobra.Command{
19+
Use: "path",
20+
Short: "Show path to [global] devbox config",
21+
PreRunE: ensureNixInstalled,
22+
Args: cobra.ExactArgs(0),
23+
RunE: func(cmd *cobra.Command, args []string) error {
24+
fmt.Println(flags.config.path)
25+
return nil
26+
},
27+
}
28+
29+
flags.config.register(cmd)
30+
31+
return cmd
32+
}

0 commit comments

Comments
 (0)