Skip to content

How to set the prog name of a group? #2642

@anemele

Description

@anemele

Hi, there.

argparse

I have a package xxx and use argparse to create a CLI, and use a batch script to call it.

In xxx/__main__ I can pass __package__ to prog to set the program name as xxx

  parser = argparse.ArgumentParser(prog=__package__, description=__doc__)

batch script xxx.bat

@echo off
setlocal
set PYTHONPATH=%~dp0;%PYTHONPATH%
call python -m %~n0 %*

argparse is not easy to use, so I migrate to click.

click

use click, I pass __package__ to name but it not works. (I don't know exactly what the parameter name is :)

@click.group(name=__package__)

I find click will auto detect the program name by _detect_program_name() at click/utils.py:523

Is it able to set by user?

Metadata

Metadata

Assignees

No one assigned

    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