Skip to content

Command with a default arg fails to run when omitting the argument #1483

Open
@alpinweis

Description

In order to let us help you better, please fill out the following fields as best you can:

I am...

  • Reporting a bug
  • Suggesting a new feature
  • Requesting help with running my bot
  • Requesting help writing plugins
  • Here about something else

I am running...

  • Errbot version: 6.1.6
  • OS version: ubuntu 18.04
  • Python version: 3.6.9
  • Using a virtual environment: docker
  • Backend: slack

Issue description

I have a command with an argument. I'd like it to work with a default value if the argument is omitted.

@arg_botcmd("service_name", type=str, default="myservice", help="Service name")
def getstatus(self, msg, service_name):
  ...

I get an error when I try to run it w/o an argument.

User: !getstatus myservice
Errbot: ok

User: !getstatus
Errbot: I couldn't parse the arguments; the following arguments are required: service_name

The correct/expected result would be for the command to pick the default value myservice for the missing argument service_name. I also tried to use a default arg value in the method signature, but it did not help.

def getstatus(self, msg, service_name="myservice"):

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions