var openUrl = require('./utils/open-url')
var log = require('npmlog')
var fetchPackageMetadata = require('./fetch-package-metadata.js')
var usage = require('./utils/usage')
docs.completion = function (opts, cb) {
// FIXME: there used to be registry completion here, but it stopped making
// sense somewhere around 50,000 packages on the registry
function docs (args, cb) {
if (!args || !args.length) args = ['.']
var pending = args.length
args.forEach(function (proj) {
getDoc(proj, function (err) {
function getDoc (project, cb) {
log.silly('getDoc', project)
fetchPackageMetadata(project, '.', {fullMetadata: true}, function (er, d) {
if (!url) url = 'https://www.npmjs.org/package/' + d.name
return openUrl(url, 'docs available at the following URL', cb)