Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command-line functionality to uuid module #88597

Closed
ephenix mannequin opened this issue Jun 16, 2021 · 10 comments
Closed

Add command-line functionality to uuid module #88597

ephenix mannequin opened this issue Jun 16, 2021 · 10 comments
Assignees
Labels
3.12 bugs and security fixes type-feature A feature request or enhancement

Comments

@ephenix
Copy link
Mannequin

ephenix mannequin commented Jun 16, 2021

BPO 44431
Nosy @serhiy-storchaka, @erlend-aasland, @ephenix
PRs
  • bpo-44431: Added command line functionality to UUID module. #26751
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-06-16.04:14:46.410>
    labels = ['type-feature', '3.11']
    title = 'Add command-line functionality to uuid module'
    updated_at = <Date 2021-06-16.22:06:09.458>
    user = 'https://github.com/ephenix'

    bugs.python.org fields:

    activity = <Date 2021-06-16.22:06:09.458>
    actor = 'erlendaasland'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2021-06-16.04:14:46.410>
    creator = 'ephenix'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44431
    keywords = ['patch']
    message_count = 2.0
    messages = ['395906', '395967']
    nosy_count = 3.0
    nosy_names = ['serhiy.storchaka', 'erlendaasland', 'ephenix']
    pr_nums = ['26751']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44431'
    versions = ['Python 3.11']

    Linked PRs

    @ephenix
    Copy link
    Mannequin Author

    ephenix mannequin commented Jun 16, 2021

    Suggested functionality:

    python -m uuid
    b9aa5a06-e2cd-4c26-b26b-1590f01ea996

    @ephenix ephenix mannequin added 3.11 only security fixes type-feature A feature request or enhancement labels Jun 16, 2021
    @serhiy-storchaka
    Copy link
    Member

    I think it would be a useful feature.

    But would not be better to make interface similar to interface of standard Linux command uuidgen? In any case it should support the -h or --help options.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @achhina
    Copy link
    Contributor

    achhina commented Nov 7, 2022

    @ephenix would you still like to work on this as I see you've closed your PR? If not, I'd like to work on this; I'll wait a couple of days to give you a chance to respond if you'd still like to continue.

    @ephenix
    Copy link

    ephenix commented Nov 10, 2022

    @ephenix would you still like to work on this as I see you've closed your PR? If not, I'd like to work on this; I'll wait a couple of days to give you a chance to respond if you'd still like to continue.

    I lost track of this -- feel free to take my pull request and do anything necessary to get it merged. IIRC the changes I made were working.

    achhina added a commit to achhina/cpython that referenced this issue Nov 14, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 14, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 14, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 14, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 15, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 15, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 15, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 15, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 15, 2022
    achhina added a commit to achhina/cpython that referenced this issue Nov 16, 2022
    achhina added a commit to achhina/cpython that referenced this issue Jan 22, 2023
    @gpshead gpshead added 3.12 bugs and security fixes and removed 3.11 only security fixes labels Jan 22, 2023
    @gpshead gpshead self-assigned this Jan 22, 2023
    gpshead pushed a commit that referenced this issue Jan 22, 2023
    The `uuid` module now supports command line usage.
    
    ```python
    ❯ ./python.exe -m uuid             
    5f2d57b1-90e8-417c-ba5d-69b9b6f74289
    
    ❯ ./python.exe -m uuid -h          
    usage: uuid.py [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-ns NAMESPACE] [-n NAME]
    ...
    ```
    @gpshead
    Copy link
    Member

    gpshead commented Jan 22, 2023

    thanks for the contribution.

    @gpshead gpshead closed this as completed Jan 22, 2023
    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution @achhina. But I have few nitpicks:

    1. Most CLI tools on Unix and Linux use minus followed by a single letter as short options, and double minus followed by a sequence of letters as long option. An alternative style used in minority of commands (e.g. find and java) use single minus for long options. But your proposition mixes the styles: there are short options like -u, long options like --name, and also long option with a single minus -ns. argparse of course supports both styles, but I was surprised that it supports a mix, and I am not sure that it will not be broken in future (-ns can be interpreted as two separate options -n and -s).
    2. Standard Linux utility uuidgen has similar interface, but conflicting short options. -n is a short alias of --namespace, and -N is a short alias of --name. As you see option -n has different semantic.
    3. uuidgen accepts namespace argument in form: @dns @url @oid @x500. In your proposition it should be in form: NAMESPACE_DNS NAMESPACE_URL NAMESPACE_OID NAMESPACE_X500. And it is not documented.

    I propose to rename -n to -N and -ns to -n, and accept simpler compatible namespace syntax.

    @achhina
    Copy link
    Contributor

    achhina commented Jan 22, 2023

    @serhiy-storchaka that makes sense, I can create a follow-up patch in regards to the proposed changes if everyone agrees - cc @gpshead.

    @gpshead
    Copy link
    Member

    gpshead commented Jan 22, 2023

    Good thinking Serhiy, those changes makes sense to me.

    @gpshead gpshead reopened this Jan 22, 2023
    @gpshead
    Copy link
    Member

    gpshead commented Jan 22, 2023

    Just @ me on the PR when you've created one @achhina.

    achhina added a commit to achhina/cpython that referenced this issue Jan 22, 2023
    gpshead pushed a commit that referenced this issue Jan 25, 2023
    …1248)
    
    this way they match an existing uuidgen command line tool.
    @gpshead
    Copy link
    Member

    gpshead commented Jan 25, 2023

    thanks for the contribution!

    @gpshead gpshead closed this as completed Jan 25, 2023
    iritkatriel pushed a commit to iritkatriel/cpython that referenced this issue Jan 25, 2023
    python#101248)
    
    this way they match an existing uuidgen command line tool.
    mdboom pushed a commit to mdboom/cpython that referenced this issue Jan 31, 2023
    python#101248)
    
    this way they match an existing uuidgen command line tool.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.12 bugs and security fixes type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants