Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Running python3-pip-skeleton with no arguments generates unhelpful error #79

@AlexanderWells-diamond

Description

@AlexanderWells-diamond
$ python3-pip-skeleton
Traceback (most recent call last):
  File "/home/eyh46967/dev/python3-pip-skeleton-cli/venv/bin/python3-pip-skeleton", line 8, in <module>
    sys.exit(main())
  File "/home/eyh46967/dev/python3-pip-skeleton-cli/src/python3_pip_skeleton/__main__.py", line 264, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

This error is unhelpful. I would expect the help message to be displayed if no arguments are given.

I personally solved this recently with the following extended ArgumentParser:

    class CustomParser(ArgumentParser):
        def error(self, message):
            # Without this, calling the module with no command line arguments
            # only prints an error message, not the help or usage
            sys.stderr.write("error: %s\n" % message)
            self.print_help()
            sys.exit(2)

    parser = CustomParser(prog="github_members")

but I'm sure there are many ways to solve this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions