﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25419	Management commands: allow to set exit code, without calling sys.exit	Daniel Hahler	nobody	"With a Command like the following, it would be nice to be able to specify the exit code in case of errors:

{{{
class Command(LabelCommand):
    def handle_label(self, username, **options):
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            self.stderr.write(""{}: user not found, skipping."".format(username))
            self.exitcode = 5
            return
        result = do_something()
        self.stdout.write(""{}: {}"".format(username, result))
}}}

While you could call `sys.exit(5)` directly in this case, the use case would be to handle all existing users from the labels, but exit non-zero in case of any errors.

I could imagine having `exitcode = 0` on the `BaseCommand` class and then use this in the end with `sys.exit()`.
"	New feature	closed	Core (Management commands)	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
