mirror of https://github.com/databricks/cli.git
some cleanup
This commit is contained in:
parent
112a9de90a
commit
647dab0a66
|
@ -0,0 +1,2 @@
|
||||||
|
bundle:
|
||||||
|
name: foobar
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
>>> [CLI] bundle exec -- doesnotexist arg1 arg2 --flag1 --flag2
|
||||||
|
Error: Running "doesnotexist arg1 arg2 --flag1 --flag2" failed: exec: "doesnotexist": executable file not found in $PATH
|
||||||
|
|
||||||
|
Exit code: 1
|
|
@ -0,0 +1 @@
|
||||||
|
trace $CLI bundle exec -- doesnotexist arg1 arg2 --flag1 --flag2
|
|
@ -20,6 +20,15 @@ func (e *exitCodeErr) Error() string {
|
||||||
return fmt.Sprintf("Running %q failed with exit code: %d", strings.Join(e.args, " "), e.exitCode)
|
return fmt.Sprintf("Running %q failed with exit code: %d", strings.Join(e.args, " "), e.exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type runErr struct {
|
||||||
|
err error
|
||||||
|
args []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *runErr) Error() string {
|
||||||
|
return fmt.Sprintf("Running %q failed: %s", strings.Join(e.args, " "), e.err)
|
||||||
|
}
|
||||||
|
|
||||||
func newExecCommand() *cobra.Command {
|
func newExecCommand() *cobra.Command {
|
||||||
execCmd := &cobra.Command{
|
execCmd := &cobra.Command{
|
||||||
Use: "exec",
|
Use: "exec",
|
||||||
|
@ -84,13 +93,8 @@ Example usage:
|
||||||
childCmd.Stdout = cmd.OutOrStdout()
|
childCmd.Stdout = cmd.OutOrStdout()
|
||||||
childCmd.Stderr = cmd.ErrOrStderr()
|
childCmd.Stderr = cmd.ErrOrStderr()
|
||||||
|
|
||||||
// Start the command
|
// Run the command.
|
||||||
if err := childCmd.Start(); err != nil {
|
err := childCmd.Run()
|
||||||
return fmt.Errorf("Error starting command: %s\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the command to finish.
|
|
||||||
err := childCmd.Wait()
|
|
||||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
// We don't make the parent CLI process exit with the same exit code
|
// We don't make the parent CLI process exit with the same exit code
|
||||||
// as the child process because the exit codes for the CLI have not
|
// as the child process because the exit codes for the CLI have not
|
||||||
|
@ -104,7 +108,10 @@ Example usage:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error waiting for command: %w", err)
|
return &runErr{
|
||||||
|
err: err,
|
||||||
|
args: args,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue