Dvc: Provide suggestions on typo of command

Created on 15 Jun 2020  路  3Comments  路  Source: iterative/dvc

$ git commti
git: 'commti' is not a git command. See 'git --help'.

The most similar command is
        commit

vs

$ dvc commti
ERROR: argument COMMAND: invalid choice: 'commti' (choose from 'init', 'get', 'get-url', 'destroy', 'add', 'remove', 'move', 'unprotect', 'run', 'repro', 'pull', 'push', 'fetch', 'status', 'gc', 'import', 'import-url', 'config', 'checkout', 'remote', 'cache', 'metrics', 'params', 'install', 'root', 'list', 'freeze', 'unfreeze', 'dag', 'daemon', 'commit', 'diff', 'version', 'update', 'git-hook', 'plots')
usage: dvc [-q | -v] [-h] [-V] COMMAND ...

Data Version Control

optional arguments:
  -q, --quiet    Be quiet.
  -v, --verbose  Be verbose.
  -h, --help     Show this help message and exit.
  -V, --version  Show program's version.

Available Commands:
  COMMAND        Use `dvc COMMAND --help` for command-specific help.
    init         Initialize DVC in the current directory.
    get          Download file or directory tracked by DVC or by Git.
    get-url      Download or copy files from URL.
    destroy      Remove DVC-files, local DVC config and data cache.
    add          Track data files or directories with DVC.
    remove       Remove stage entry and unprotect outputs
    move         Rename or move a DVC controlled data file or a directory.
    unprotect    Unprotect tracked files or directories (when hardlinks or symlinks have been enabled with `dvc config cache.type`)
    run          Generate a stage file from a command and execute the command.
    repro        Reproduce complete or partial pipelines by executing their stages.
    pull         Download tracked files or directories from remote storage.
    push         Upload tracked files or directories to remote storage.
    fetch        Get tracked files or directories from remote storage into the cache.
    status       Show changed stages, compare local cache and a remote storage.
    gc           Garbage collect unused objects from cache or remote storage.
    import       Download file or directory tracked by DVC or by Git into the workspace, and track it.
    import-url   Download or copy file from URL and take it under DVC control.
    config       Get or set config options.
    checkout     Checkout data files from cache.
    remote       Set up and manage data remotes.
    cache        Manage cache settings.
    metrics      Commands to display and compare metrics.
    params       Commands to display params.
    install      Install DVC git hooks into the repository.
    root         Return the relative path to the root of the DVC project.
    list         List repository contents, including files and directories tracked by DVC and by Git.
    freeze       Freeze DVC-files.
    unfreeze     Unfreeze DVC-files.
    dag          Visualize DVC project DAG.
    commit       Save changed data to cache and update DVC-files.
    diff         Show added, modified, or deleted data between commits in the DVC repository, or between a commit and the workspace.
    version      Display the DVC version and system/environment information.
    update       Update data artifacts imported from other DVC repositories.
    plots        Commands to visualize and compare plot metrics in structured files (JSON, YAML, CSV, TSV)

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
enhancement help wanted p2-medium ui

Most helpful comment

Happy to look more into this. It looks like dvc uses Python's command-line parsing to determine what command to run. If the command argument passed in doesn't match up with the dvc commands, then it prints out the help text as listed in the original issue.

I think this issue could be solved by first checking to see if the arguments passed in are similar to any of the existing dvc commands. This similarity check can be done using the Levenshtein distance algorithm.

If there are any similar commands, display the suggestions. If not, display the help text.

All 3 comments

Can anyone from the community work on this issue? I agree there should be some suggestions if the typo is similar to some other dvc commands and would like to work on this.

@santos22 feel free to take it! Thanks for your interest in this.

Happy to look more into this. It looks like dvc uses Python's command-line parsing to determine what command to run. If the command argument passed in doesn't match up with the dvc commands, then it prints out the help text as listed in the original issue.

I think this issue could be solved by first checking to see if the arguments passed in are similar to any of the existing dvc commands. This similarity check can be done using the Levenshtein distance algorithm.

If there are any similar commands, display the suggestions. If not, display the help text.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmpetrov picture dmpetrov  路  3Comments

ghost picture ghost  路  3Comments

gregfriedland picture gregfriedland  路  3Comments

siddygups picture siddygups  路  3Comments

TezRomacH picture TezRomacH  路  3Comments