| 27 | static params = ['viewer'] |
| 28 | |
| 29 | static async completion (opts, npm) { |
| 30 | if (opts.conf.argv.remain.length > 2) { |
| 31 | return [] |
| 32 | } |
| 33 | const g = path.resolve(npm.npmRoot, 'man/man[0-9]/*.[0-9]') |
| 34 | let files = await glob(globify(g)) |
| 35 | // preserve glob@8 behavior |
| 36 | files = files.sort((a, b) => a.localeCompare(b, 'en')) |
| 37 | |
| 38 | return Object.keys(files.reduce(function (acc, file) { |
| 39 | file = path.basename(file).replace(/\.[0-9]+$/, '') |
| 40 | file = file.replace(/^npm-/, '') |
| 41 | acc[file] = true |
| 42 | return acc |
| 43 | }, { help: true })) |
| 44 | } |
| 45 | |
| 46 | async exec (args) { |
| 47 | // By default we search all of our man subdirectories, but if the user has asked for a specific one we limit the search to just there |