Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-157

MONGODB-CR default value breaks formatting for tools help output

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 2.8.0-rc1
    • Affects Version/s: Legacy C++ Implementation
    • Component/s: None

      Here's the help output (2.4.4, mongodump):

      options:
        --help                                produce help message
        -v [ --verbose ]                      be more verbose (include multiple times
                                              for more verbosity e.g. -vvvvv)
        --version                             print the program's version and exit
        -h [ --host ] arg                     mongo host to connect to ( <set 
                                              name>/s1,s2 for sets)
        --port arg                            server port. Can also use --host 
                                              hostname:port
        --ipv6                                enable IPv6 support (disabled by 
                                              default)
        -u [ --username ] arg                 username
        -p [ --password ] arg                 password
        --authenticationDatabase arg          user source (defaults to dbname)
        --authenticationMechanism arg (=MONGODB-CR)
                                              authentication mechanism
        --dbpath arg                          directly access mongod database files 
                                              in the given path, instead of 
                                              connecting to a mongod  server - needs 
                                              to lock the data directory, so cannot 
                                              be used if a mongod is currently 
                                              accessing the same path
        --directoryperdb                      each db is in a separate directly 
                                              (relevant only if dbpath specified)
        --journal                             enable journaling (relevant only if 
                                              dbpath specified)
        -d [ --db ] arg                       database to use
        -c [ --collection ] arg               collection to use (some commands)
        --objcheck                            validate object before inserting 
                                              (default)
        --noobjcheck                          don't validate object before inserting
        --filter arg                          filter to apply before inserting
        --drop                                drop each collection before import
        --oplogReplay                         replay oplog for point-in-time restore
        --oplogLimit arg                      include oplog entries before the 
                                              provided Timestamp (seconds[:ordinal]) 
                                              during the oplog replay; the ordinal 
                                              value is optional
        --keepIndexVersion                    don't upgrade indexes to newest version
        --noOptionsRestore                    don't restore collection options
        --noIndexRestore                      don't restore indexes
        --w arg (=0)                          minimum number of replicas per write
      

      Note the authenticationMechanism line. If we move the default value to a note (the same as dbname in the line above it) you get this:

      ./mongodump  --help
      Export MongoDB data to BSON files.
      
      options:
        --help                        produce help message
        -v [ --verbose ]              be more verbose (include multiple times for 
                                      more verbosity e.g. -vvvvv)
        --quiet                       silence all non error diagnostic messages
        --version                     print the program's version and exit
        -h [ --host ] arg             mongo host to connect to ( <set name>/s1,s2 for
                                      sets)
        --port arg                    server port. Can also use --host hostname:port
        --ipv6                        enable IPv6 support (disabled by default)
        -u [ --username ] arg         username
        -p [ --password ] arg         password
        --authenticationDatabase arg  user source (defaults to dbname)
        --authenticationMechanism arg authentication mechanism (defaults to 
                                      MONOGDB-CR)
        --dbpath arg                  directly access mongod database files in the 
                                      given path, instead of connecting to a mongod  
                                      server - needs to lock the data directory, so 
                                      cannot be used if a mongod is currently 
                                      accessing the same path
        --directoryperdb              each db is in a separate directly (relevant 
                                      only if dbpath specified)
        --journal                     enable journaling (relevant only if dbpath 
                                      specified)
        -d [ --db ] arg               database to use
        -c [ --collection ] arg       collection to use (some commands)
        -o [ --out ] arg (=dump)      output directory or "-" for stdout
        -q [ --query ] arg            json query
        --oplog                       Use oplog for point-in-time snapshotting
        --repair                      try to recover a crashed database
        --forceTableScan              force a table scan (do not use $snapshot)
      

      Here's the change (can do a pull request if needed), it's a two line change:

      git diff
      diff --git a/src/mongo/tools/tool.cpp b/src/mongo/tools/tool.cpp
      index b54db16..24904f7 100644
      --- a/src/mongo/tools/tool.cpp
      +++ b/src/mongo/tools/tool.cpp
      @@ -74,8 +74,8 @@ namespace mongo {
                    po::value<string>(&_authenticationDatabase)->default_value(""),
                    "user source (defaults to dbname)" )
                   ("authenticationMechanism",
      -             po::value<string>(&_authenticationMechanism)->default_value("MONGODB-CR"),
      -             "authentication mechanism")
      +             po::value<string>(&_authenticationMechanism)->default_value(""),
      +             "authentication mechanism (defaults to MONOGDB-CR)")
                   ;
       
               if ( access & LOCAL_SERVER )
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            ian@mongodb.com Ian Whalen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: