Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.0.7, 2.2.0
    • Fix Version/s: None
    • Component/s: Tools

      Description

      Specially on Windows:

      When specifying a file to import with --file with a space (without double quotes),

      > mongoimport -d db -c coll --file D:\Parsely data\articles_split.json

      mongoimport will *not* display:

      Mon Oct  8 10:03:02 ERROR: file doesn't exist: filename.

      But

      ERROR: multiple occurrences
       
      Import CSV, TSV or JSON data into MongoDB.
       
      options:
      ...

      This is misleading because it seems it refers to multiple document occurrences.

      Same error occurs on Mac:

      > mongoimport -d test -c test --file test space.json
      ERROR: multiple occurrences

        Activity

        Hide
        tad Tad Marshall added a comment -

        This exception is thrown by Boost::program_options because it sees two filenames specified: "D:\Parsely" and "data\articles_split.json". We display "ERROR: " followed by the text of the Boost::program_options::multiple_occurrences exception, which is "multiple occurrences", and then display the command line options help text. You get the same behavior if you provide two collection names or two database names.

        Show
        tad Tad Marshall added a comment - This exception is thrown by Boost::program_options because it sees two filenames specified: "D:\Parsely" and "data\articles_split.json". We display "ERROR: " followed by the text of the Boost::program_options::multiple_occurrences exception, which is "multiple occurrences", and then display the command line options help text. You get the same behavior if you provide two collection names or two database names.
        Hide
        gianfranco Gianfranco Palumbo added a comment -

        I understand you point, but wouldn't it be better "multiple command line options occurrences" or something similar to help avoid the confusion?

        Show
        gianfranco Gianfranco Palumbo added a comment - I understand you point, but wouldn't it be better "multiple command line options occurrences" or something similar to help avoid the confusion?
        Hide
        tad Tad Marshall added a comment -

        I wasn't actually trying to make a point, just describe what is happening and why this is the error message you see.

        This is certainly fixable with the addition of some code. We have access to the same argc/argv parameters that we are passing to Boost::program_options and we could add parsing that was better tuned to detecting typos and unquoted file specs with spaces. We could probably allow multiple occurrences of options and then complain after program_options gives them to us, so that program_options will not throw an exception, and then we could make our error message better.

        I agree that this is an unfriendly and unhelpful error message.

        Show
        tad Tad Marshall added a comment - I wasn't actually trying to make a point, just describe what is happening and why this is the error message you see. This is certainly fixable with the addition of some code. We have access to the same argc/argv parameters that we are passing to Boost::program_options and we could add parsing that was better tuned to detecting typos and unquoted file specs with spaces. We could probably allow multiple occurrences of options and then complain after program_options gives them to us, so that program_options will not throw an exception, and then we could make our error message better. I agree that this is an unfriendly and unhelpful error message.
        Hide
        gianfranco Gianfranco Palumbo added a comment -

        $ mongoimport --version
         version 2.6.3
        $ mongoimport -d test -c test --file test space.json
        Error parsing command line:  Multiple occurrences of option "--file"
        try 'mongoimport --help' for more information

        Show
        gianfranco Gianfranco Palumbo added a comment - $ mongoimport --version version 2.6.3 $ mongoimport -d test -c test --file test space.json Error parsing command line: Multiple occurrences of option "--file" try 'mongoimport --help' for more information

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since reply:
              41 weeks, 4 days ago
              Date of 1st Reply: