MCPcopy Index your code
hub / github.com/jetify-com/devbox / shellEnvFunc

Function shellEnvFunc

internal/boxcli/shellenv.go:96–161  ·  view source on GitHub ↗
(
	cmd *cobra.Command,
	flags shellEnvCmdFlags,
)

Source from the content-addressed store, hash-verified

94}
95
96func shellEnvFunc(
97 cmd *cobra.Command,
98 flags shellEnvCmdFlags,
99) (string, error) {
100 env, err := flags.Env(flags.config.path)
101 if err != nil {
102 return "", err
103 }
104 ctx := cmd.Context()
105 if flags.recomputeEnv {
106 ctx = ux.HideMessage(ctx, devbox.StateOutOfDateMessage)
107 }
108 box, err := devbox.Open(&devopt.Opts{
109 Dir: flags.config.path,
110 Environment: flags.config.environment,
111 Stderr: cmd.ErrOrStderr(),
112 Env: env,
113 })
114 if err != nil {
115 return "", err
116 }
117
118 if flags.install {
119 if err := box.Install(ctx); err != nil {
120 return "", err
121 }
122 }
123
124 // Convert format string to ShellFormat type
125 var shellFormat devopt.ShellFormat
126 switch flags.format {
127 case "nushell":
128 shellFormat = devopt.ShellFormatNushell
129 default:
130 shellFormat = devopt.ShellFormatBash
131 }
132
133 envStr, err := box.EnvExports(ctx, devopt.EnvExportsOpts{
134 EnvOptions: devopt.EnvOptions{
135 Hooks: devopt.LifecycleHooks{
136 OnStaleState: func() {
137 if !flags.recomputeEnv {
138 ux.FHidableWarning(
139 ctx,
140 cmd.ErrOrStderr(),
141 devbox.StateOutOfDateMessage,
142 box.RefreshAliasOrCommand(),
143 )
144 }
145 },
146 },
147 OmitNixEnv: flags.omitNixEnv,
148 PreservePathStack: flags.preservePathStack,
149 Pure: flags.pure,
150 SkipRecompute: !flags.recomputeEnv,
151 },
152 NoRefreshAlias: flags.noRefreshAlias,
153 RunHooks: flags.runInitHook,

Callers 1

shellEnvCmdFunction · 0.85

Calls 7

HideMessageFunction · 0.92
OpenFunction · 0.92
FHidableWarningFunction · 0.92
EnvExportsMethod · 0.80
RefreshAliasOrCommandMethod · 0.80
EnvMethod · 0.65
InstallMethod · 0.45

Tested by

no test coverage detected