Uploaded image for project: 'Picard'
  1. Picard
  2. PICARD-3025

positional arguments cli calls are not being parsed the way picard --help indicates.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 2.12.3
    • User Interface
    • None
    • GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)

       

      $ picard --help --version
      usage: picard [-h] [-a AUDIT] [-c CONFIG_FILE] [-d] [-e COMMAND [COMMAND ...]] [-M] [-N] [-P] [--no-crash-dialog]
                    [-s] [-v] [-V]
                    [FILE_OR_URL ...]
      positional arguments:
        FILE_OR_URL           the file(s), URL(s) and MBID(s) to load⋮
      {{}}
      $ picard -e cluster -e lookup clustered .
      I: 23:45:59,894 tagger.main:1546: Sending messages to main instance: ['cluster ', 'lookup clustered', 'lookup .']
      qt.qpa.qgnomeplatform.theme: The desktop style for QtQuick Controls 2 applications is not available on the system (qqc2-desktop-style). The application may look broken.
      QApplication: invalid style override 'Adwaita-Dark' passed, ignoring it.
                Available styles: kvantum-dark, kvantum, Windows, Fusion
      Warning: config file 3.0.0.dev2 was created by a more recent version of Picard (current is 2.12.3.final0)
      W: 23:46:01,598 pluginmanager.plugin_error:229: Plugin "Add Cluster As Release" from "/home/$USER/.config/MusicBrainz/Picard/plugins/addrelease.py" is not compatible with this version of Picard.
      ⋮W: 23:46:01,959 ui/playertoolbar.{}init{}:106: Internal player: unavailable, cannot import name 'QtMultimedia' from 'PyQt5' (/usr/lib/python3/dist-packages/PyQt5/{}init{}.py)
      E: 23:46:02,340 tagger.handle_command_lookup:522: Invalid LOOKUP command argument: '.'
      ^Z
      [1]+  Stopped                 picard -e cluster -e lookup clustered .
      $ bg; picard . -e cluster -e lookup clustered &
      [4]+ picard -e cluster -e lookup clustered . &
      [5] 2872200
      $ I: 00:08:18,429 tagger.main:1546: Sending messages to main instance: ['LOAD /library/music', 'cluster ', 'lookup clustered'][5]+  Exit 195                picard . -e cluster -e lookup clustered
      $ 
       
      

       

      When called as picard -e <command> <path> it fails to load the <path>.  In the example above it is `.` but I've used the absolute path as well and it fails as well.

      When called as picard <path> -e <command>, it loads.  

      So that leads me to the conclusion that either it isn't parsing those positional arguments the way it was presumably intended based on picard --help OR the --help is wrong and the positional arguments belong before the flags.

       

       

          [PICARD-3025] positional arguments cli calls are not being parsed the way picard --help indicates.

          iconclast hero added a comment - - edited

          outsidecontext That makes sense in terms of how the shell operates, but in looking at the --help:

          If one of the filenames begins with a hyphen, use – to separate the options from the filenames.

          So WRT to the disposition of this ticket I would say that we can change the ticket to `--help vague in terms of passing both a -e <command> and <path>`.  While it is not super duper common for --help to include specific examples of usage, it's not unknown either.  Perhaps adding something like a condensed version of the following would help to avoid confusion.

          All the argument passed after the -e parameter go into this parameter. The -e accepts an arbitrary number of arguments, so all arguments after this go into this command, until another flag starting with a dash comes.

          You can separate the positional arguments with "--" to make sure they get interpreted not as part of the parameters:

          picard -e cluster -e lookup clustered -- some/path

          Or use the "load" command:

          picard -e load some/path -e cluster -e lookup clustered

          So at this point, that's up to you to consider and dispose of this ticket as you see fit.  Thanks for the explanation.

          iconclast hero added a comment - - edited outsidecontext That makes sense in terms of how the shell operates, but in looking at the --help: If one of the filenames begins with a hyphen, use – to separate the options from the filenames. So WRT to the disposition of this ticket I would say that we can change the ticket to `--help vague in terms of passing both a -e <command> and <path>`.  While it is not super duper common for --help to include specific examples of usage, it's not unknown either.  Perhaps adding something like a condensed version of the following would help to avoid confusion. All the argument passed after the -e parameter go into this parameter. The -e accepts an arbitrary number of arguments, so all arguments after this go into this command, until another flag starting with a dash comes. You can separate the positional arguments with "--" to make sure they get interpreted not as part of the parameters: picard -e cluster -e lookup clustered -- some/path Or use the "load" command: picard -e load some/path -e cluster -e lookup clustered So at this point, that's up to you to consider and dispose of this ticket as you see fit.  Thanks for the explanation.

          Philipp Wolfer added a comment - - edited

          All the argument passed after the -e parameter go into this parameter. The -e accepts an arbitrary number of arguments, so all arguments after this go into this command, until another flag starting with a dash comes.

          You can separate the positional arguments with "--" to make sure they get interpreted not as part of the parameters:

          picard -e cluster -e lookup clustered -- some/path

          Or use the "load" command:

          picard -e load some/path -e cluster -e lookup clustered

          Philipp Wolfer added a comment - - edited All the argument passed after the -e parameter go into this parameter. The -e accepts an arbitrary number of arguments, so all arguments after this go into this command, until another flag starting with a dash comes. You can separate the positional arguments with "--" to make sure they get interpreted not as part of the parameters: picard -e cluster -e lookup clustered -- some/path Or use the "load" command: picard -e load some/path -e cluster -e lookup clustered

          As I format the output of --help, I wonder if it's actually saying that those three separate things and the path actually does go in "$1"?  If so, it's not immediately obvious to me that is what it is trying to convey.

          iconclast hero added a comment - As I format the output of --help, I wonder if it's actually saying that those three separate things and the path actually does go in "$1"?  If so, it's not immediately obvious to me that is what it is trying to convey.

          iconclast hero added a comment - - edited

          Oh, and what did I expect?  I've been using an 'alias picard.=picard . -e cluster -e lookup clustered` for a while now and it's possible I figured this out a few months ago, but I expect that following the guidance provided by picard --help would load the files the way it does when i put the file name in "$1" counter to --help.

          iconclast hero added a comment - - edited Oh, and what did I expect?  I've been using an 'alias picard.=picard . -e cluster -e lookup clustered` for a while now and it's possible I figured this out a few months ago, but I expect that following the guidance provided by picard --help would load the files the way it does when i put the file name in "$1" counter to --help.

            Unassigned Unassigned
            iconoclasthero iconclast hero
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Version Package