Skip to content

Improve output when a non-existent command is given #30

Description

@rrthomas

Observe (tested with wajig git):

$ wajig foo
usage: wajig [-h] [-V] [<command> [--help] [--teach] [--noop] [<options>]]
wajig: error: argument {help,addcdrom,add-cdrom,addgroup,add-group,addkey,add-key,addrepo,adduser,autoalts,autoalternatives,auto-alternatives,auto-alts,autoclean,auto-clean,autodownload,auto-download,autoremove,auto-remove,build,builddeps,builddepend,builddepends,build-deps,changelog,clean,commands,listcommands,list-commands,contents,dailyupgrade,daily-upgrade,deluser,rmuser,dependents,describe,describenew,newdescribe,new-describe,describe-new,disable,disuser,lock,distupgrade,dist-upgrade,full-upgrade,download,editsources,edit-sources,enable,enuser,unlock,extract,fixconfigure,fix-configure,fixinstall,fix-install,fixmissing,fix-missing,force,hold,info,init,install,isntall,autoinstall,installsuggested,installs,suggested,install-suggested,integrity,large,lastupdate,last-update,listalternatives,listalts,list-alternatives,listall,list-all,listcache,list-cache,listdaemons,list-daemons,listgroups,list-groups,groups,listfiles,list-files,listhold,list-hold,listinstalled,list-installed,listnames,list-names,listpackages,list,list-packages,listscripts,list-scripts,listsection,list-section,listsections,list-sections,liststatus,list-status,madison,move,new,newdetail,detailnew,detail-new,new-detail,news,nonfree,non-free,orphans,orphaned,listorphaned,listorphans,password,policy,available,purge,purgedepend,purgeorphans,purge-orphans,purgeremoved,purge-removed,rbuilddeps,rbuilddep,reversebuilddeps,reverse-build-deps,readme,reboot,recdownload,recursive,rec-download,recommended,reconfigure,reinstall,re-install,reload,remove,removeorphans,remove-orphans,repackage,package,reportbug,bug,bugreport,repos,restart,rmgroup,remove-group,delgroup,rmrepo,rpm2deb,rpmtodeb,rpminstall,rpm-install,safeupgrade,safe-upgrade,search,searchapt,search-apt,show,detail,details,sizes,size,snapshot,source,start,status,stop,sysinfo,aptlog,listlog,list-log,tasksel,todo,toupgrade,newupgrades,new-upgrades,to-upgrade,upgradable,tutorial,doc,docs,documentation,unhold,unofficial,findpkg,findpackage,update,updatealternatives,updatealts,update-alts,setalts,set-alts,setalternativesset-alternatives,update-alternatives,updatepciids,update-pciids,update-pci-ids,updateusbids,update-usbids,update-usb-ids,upgrade,upgradesecurity,upgrade-security,verify,version,versions,whichpackage,findfile,find-file,locate,filesearch,file-search,whichpkg,which-package}: invalid choice: 'foo' (choose from 'help', 'addcdrom', 'add-cdrom', 'addgroup', 'add-group', 'addkey', 'add-key', 'addrepo', 'adduser', 'autoalts', 'autoalternatives', 'auto-alternatives', 'auto-alts', 'autoclean', 'auto-clean', 'autodownload', 'auto-download', 'autoremove', 'auto-remove', 'build', 'builddeps', 'builddepend', 'builddepends', 'build-deps', 'changelog', 'clean', 'commands', 'listcommands', 'list-commands', 'contents', 'dailyupgrade', 'daily-upgrade', 'deluser', 'rmuser', 'dependents', 'describe', 'describenew', 'newdescribe', 'new-describe', 'describe-new', 'disable', 'disuser', 'lock', 'distupgrade', 'dist-upgrade', 'full-upgrade', 'download', 'editsources', 'edit-sources', 'enable', 'enuser', 'unlock', 'extract', 'fixconfigure', 'fix-configure', 'fixinstall', 'fix-install', 'fixmissing', 'fix-missing', 'force', 'hold', 'info', 'init', 'install', 'isntall', 'autoinstall', 'installsuggested', 'installs', 'suggested', 'install-suggested', 'integrity', 'large', 'lastupdate', 'last-update', 'listalternatives', 'listalts', 'list-alternatives', 'listall', 'list-all', 'listcache', 'list-cache', 'listdaemons', 'list-daemons', 'listgroups', 'list-groups', 'groups', 'listfiles', 'list-files', 'listhold', 'list-hold', 'listinstalled', 'list-installed', 'listnames', 'list-names', 'listpackages', 'list', 'list-packages', 'listscripts', 'list-scripts', 'listsection', 'list-section', 'listsections', 'list-sections', 'liststatus', 'list-status', 'madison', 'move', 'new', 'newdetail', 'detailnew', 'detail-new', 'new-detail', 'news', 'nonfree', 'non-free', 'orphans', 'orphaned', 'listorphaned', 'listorphans', 'password', 'policy', 'available', 'purge', 'purgedepend', 'purgeorphans', 'purge-orphans', 'purgeremoved', 'purge-removed', 'rbuilddeps', 'rbuilddep', 'reversebuilddeps', 'reverse-build-deps', 'readme', 'reboot', 'recdownload', 'recursive', 'rec-download', 'recommended', 'reconfigure', 'reinstall', 're-install', 'reload', 'remove', 'removeorphans', 'remove-orphans', 'repackage', 'package', 'reportbug', 'bug', 'bugreport', 'repos', 'restart', 'rmgroup', 'remove-group', 'delgroup', 'rmrepo', 'rpm2deb', 'rpmtodeb', 'rpminstall', 'rpm-install', 'safeupgrade', 'safe-upgrade', 'search', 'searchapt', 'search-apt', 'show', 'detail', 'details', 'sizes', 'size', 'snapshot', 'source', 'start', 'status', 'stop', 'sysinfo', 'aptlog', 'listlog', 'list-log', 'tasksel', 'todo', 'toupgrade', 'newupgrades', 'new-upgrades', 'to-upgrade', 'upgradable', 'tutorial', 'doc', 'docs', 'documentation', 'unhold', 'unofficial', 'findpkg', 'findpackage', 'update', 'updatealternatives', 'updatealts', 'update-alts', 'setalts', 'set-alts', 'setalternativesset-alternatives', 'update-alternatives', 'updatepciids', 'update-pciids', 'update-pci-ids', 'updateusbids', 'update-usbids', 'update-usb-ids', 'upgrade', 'upgradesecurity', 'upgrade-security', 'verify', 'version', 'versions', 'whichpackage', 'findfile', 'find-file', 'locate', 'filesearch', 'file-search', 'whichpkg', 'which-package')

The output is doubly redundant. Part of the redundancy comes from listing both hyphenated and unhyphenated versions of the command names; see #29 for that.

The other part comes from argparse, as it first lists all the options, then lists them again. Unfortunately that's a problem with argparse and large numbers of subparsers; one would have to override argparse's own error-handling to fix it. Perhaps an upstream bug report would be read more sympathetically if #29 were addressed first!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions