TritonDataCenter / node-manta

Node.js SDK for Manta
75 stars 54 forks source link

msync --completion returns error if manta env vars are unset #400

Closed teutat3s closed 1 year ago

teutat3s commented 1 year ago

Manta commands like mls accept the flag mls --completion to print completion to stdout.

This does not yet work with the new msync command, it prints out the help message instead.

See below:

❯ ./node_modules/.bin/msync --completion
url is a required argument
usage: msync [OPTIONS] localdir ~~/remotedir

synchronize all files found inside `localdir` to `~~/remotedir`

examples

    manta-sync ./ ~~/stor/foo
        - sync all files in your cwd to the dir ~~/stor/foo

    manta-sync --dry-run ./ ~~/stor/foo
        - same as above, but just HEAD the data, don't PUT

    manta-sync -r ~~/stor/foo ./bar
        - sync all files from manta in ~~/stor/foo to local dir ./bar

options:
    -h, --help                          Print this help and exit.
    --version                           Print version and exit.
    -v, --verbose                       Verbose trace logging.

  Manta connection options:
    -a ACCOUNT, --account=ACCOUNT       Manta Account (login name). Environment:
                                        MANTA_USER=ACCOUNT
    --user=USER, --subuser=USER         Manta User (login name). Environment:
                                        MANTA_SUBUSER=USER
    --role=ROLE,ROLE,...                Assume a role. Use multiple times or
                                        once with a list. Environment:
                                        MANTA_ROLE=ROLE,ROLE,...
    -i, --insecure                      Do not validate SSL certificate.
                                        Environment: MANTA_TLS_INSECURE=1
    -k FP, --keyId=FP                   SSH key fingerprint. Environment:
                                        MANTA_KEY_ID=FP
    -u URL, --url=URL                   Manta URL. Environment: MANTA_URL=URL

  msync options:
    -c COPIES, --copies=COPIES          number of copies to make.
    -d, --delete                        delete files on the remote end not found
                                        locally.
    -x ARG, --exclude=ARG               a pattern to ignore when searching the
                                        local filesystem.
    -H HEADER, --header=HEADER          HTTP headers to include.
    -j, --just-delete                   don't send local files, just delete
                                        extra remote files.
    -l, --ignore-links                  ignore symlinks.
    -m, --md5                           use md5 instead of file size (slower,
                                        but more accurate).
    -n, --dry-run                       don't perform any remote PUT or DELETE
                                        operations.
    -p CONCURRENCY, --parallel=CONCURRENCY
                                        limit concurrent operations.
    -q, --quiet                         suppress all output.
    -r, --reverse                       manta to local sync.

EDIT: Confirmed the test suite also fails on the completion unit test, when running

make test TEST_FILTER=unit/

EDIT2: Culprit is probably in https://github.com/TritonDataCenter/node-manta/blob/master/bin/msync#L181-L188, similar to: https://github.com/TritonDataCenter/node-manta/issues/213

bahamat commented 1 year ago

I can't reproduce this.

] make test TEST_FILTER=unit
test/unit/completion.test.js ........................ 54/54
test/unit/options.test.js ........................... 60/60
test/unit/trackmarker.test.js ....................... 73/73
test/unit/utils.test.js ............................. 32/32
total ............................................. 219/219

  219 passing (4s)

  ok

And

] ./bin/msync --completion | head
#!/bin/bash
#
# Bash completion generated for 'msync' at Mon Sep 18 2023 11:26:19 GMT-0700 (Pacific Daylight Time).
#
# The original template lives here:
# https://github.com/trentm/node-dashdash/blob/master/etc/dashdash.bash_completion.in
#

#
# Copyright 2016 Trent Mick
teutat3s commented 1 year ago

Do you have any MANTA_* env vars set when running the test suite and ./bin/msync --completion?

EDIT: I can confirm that the issue does not arise when MANTA_* env vars are set. This does not happen with other commands.