Skip to content

Functions should return correct return code #150

@digitalghost-dev

Description

@digitalghost-dev

When a user uses a command that should return an error, the program will display a stylized error message but the return code is 0.

Update to the HandleCommandOutput() function.

Current:

func HandleCommandOutput(fn func() (string, error)) func() {
	return func() {
		output, err := fn()
		if err != nil {
			fmt.Fprintln(os.Stderr, output)
			return
		}
		fmt.Println(output)
	}
}

New:

func HandleCommandOutput(fn func() (string, error)) func() int {
	return func() int {
		output, err := fn()
		if err != nil {
			fmt.Fprintln(os.Stderr, output)
			return 1
		}
		fmt.Println(output)
		return 0
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/fixSomething isn't working or needs updating.

    Projects

    Status

    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions