Skip to content

Inconsistent return types between Cmd.cmdloop and Cmd.onecmd #1546

@neoniobium

Description

@neoniobium

Inconsistent return types between Cmd.cmdloop and Cmd.onecmd / Cmd.onecmd_plus_hooks

Whilst cmdloop returns integer values useful for system exit codes, onecmd and onecmd_plus_hooks return booleans, which I find surprising.

Desired change

I would prefer onecmd to also return the exit_code attribute of the Cmd class. This would give consistent exit codes for applications that run interactively via cmdloop or execute a single command.

Example:

[...]

app = cmd.Cmd()

if interactive_mode:
    return app.cmdloop()
else:
    return app.onecommand(commandstring)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions